G
Guest
Hi, I've created a custom exception class that inherits from
System.ApplicationException (implemented in a similar manner to the
recommendations made in the Exception Management Architecture Guide).
My question is: What’s the correct way to throw a custom exception in the
following scenario?
Example scenario:
Custom Exception hierarchy:
+---System.Exception
| +---Application.Exception
| | +---CustomBaseAbstractException
| | | +---UtilityEx
If client code calls a function in one of Utility's types and the parameters
are two empty strings-- Is it better to throw the custom exception like this:
Throw New UtilityEx(BAD_PARAM_EX_MESSAGE)
OR-- since ArgumentException is the specific "way" to say "I can't use these
parameters" is it better to set an instance of an argumentException to the
UtilityEx ‘s "inner exception" property?
Throw New UtilityEx(New ArgumentException),BAD_PARAM_EX_MESSAGE)
Should I only use inner exceptions when catching real exceptions or can you
also just create one for the sake of specificity even though the runtime has
not thrown one?
Thanks,
-Chris
System.ApplicationException (implemented in a similar manner to the
recommendations made in the Exception Management Architecture Guide).
My question is: What’s the correct way to throw a custom exception in the
following scenario?
Example scenario:
Custom Exception hierarchy:
+---System.Exception
| +---Application.Exception
| | +---CustomBaseAbstractException
| | | +---UtilityEx
If client code calls a function in one of Utility's types and the parameters
are two empty strings-- Is it better to throw the custom exception like this:
Throw New UtilityEx(BAD_PARAM_EX_MESSAGE)
OR-- since ArgumentException is the specific "way" to say "I can't use these
parameters" is it better to set an instance of an argumentException to the
UtilityEx ‘s "inner exception" property?
Throw New UtilityEx(New ArgumentException),BAD_PARAM_EX_MESSAGE)
Should I only use inner exceptions when catching real exceptions or can you
also just create one for the sake of specificity even though the runtime has
not thrown one?
Thanks,
-Chris