adding key/value to Exception.Data & avoiding key conflicts

Z

Zytan

http://msdn2.microsoft.com/en-us/library/system.exception.data(VS.80).aspx
says:

"Avoid key conflicts by adopting a naming convention to generate
unique keys for key/value pairs. ... two applications, named Products
and Suppliers, each has a method named Sales. The Sales method in the
Products application provides the SKU of a product. The Sales method
in the Suppliers application provides the SID of a supplier. The
naming convention yields the keys, "Products.Sales.SKU" and
"Suppliers.Sales.SID"."

But, how do we get the strings "Products.Sales.SKU" and
"Suppliers.Sales.SID" without hard coding them?

Zytan
 
G

Guest

Zytan,
All they are saying is that you should use unique key values from different
methods / classes when populating the Data property of an Exception object.
It's perfectly OK to hard code the values for the keys, as long as they are
different in each class / method.
They were only making a logical suggestion. You can call your key
"Hamburger" if you like, as long as you don't try to add another "Hamburger"
key to your Exception's Data property somewhere else up the call stack.

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top