Specific Exception from custom handler

Topics: Exception Handling Application Block
May 7, 2007 at 4:53 PM

Currently the HandleException method of my exception handler returns a generic Exception. Is it possible to return a specific type of exception from a Custom Event Handler (similar to the Replace Handler)?

If I throw the custom exception (DataLayerException or BusinessLayerException) from the exception handler it gets replaced by the Application Blocks with an ExceptionHandlingException – “Unable to handle exception: 'ReplaceExceptionHandler'.”

Obviously throwing another exception within the custom handler isn’t correct. Please let me know if you have any suggestions.


May 8, 2007 at 3:35 AM
You can return a specific type of exception from your HandleException Method and that will be the exception that gets passed to the next handler.

You don't throw the exception in your handler but instead set the PostHandlingAction to NotifyRethrow or ThrowNewException depending on how you want to throw the specific exception.




David Hayden
Microsoft MVP C#