Quick question.
When you guys throw an ArgumentExcepti on (or one of its deriviatives)
from a property setter, what do you use as the argument to the
exception's constructor? For instance:
Throw New ArgumentOutOfRa ngeException("v alue")
Passing "value" seems less helpful than it should be; you have to
examine the call stack to determine which property threw the
exception. I am sorely tempted in many cases to use the name of the
property, but I know that this isn't the recommended practice.
On the other hand, I've considered a series of exception classes
similar to ArgumentExcepti on: PropertyExcepti on. These would take the
property name rather than the argument name. That way, the name
semantics are preserved and everyone's happy.
How do you guys deal with this scenario? Do you just suck it up and
use "value"?
Thanks!
When you guys throw an ArgumentExcepti on (or one of its deriviatives)
from a property setter, what do you use as the argument to the
exception's constructor? For instance:
Throw New ArgumentOutOfRa ngeException("v alue")
Passing "value" seems less helpful than it should be; you have to
examine the call stack to determine which property threw the
exception. I am sorely tempted in many cases to use the name of the
property, but I know that this isn't the recommended practice.
On the other hand, I've considered a series of exception classes
similar to ArgumentExcepti on: PropertyExcepti on. These would take the
property name rather than the argument name. That way, the name
semantics are preserved and everyone's happy.
How do you guys deal with this scenario? Do you just suck it up and
use "value"?
Thanks!
Comment