Exception Handling in Enterprise Library 5.0

Topics: Exception Handling Application Block
May 24, 2010 at 10:19 AM
Edited May 24, 2010 at 10:21 AM

I want to set different exception handling according to exception message instead of exception type. How to do?

For example:

Based on Exception A, if his message is "1", I want to attach logging handle, otherwise, it will do nothing.

May 24, 2010 at 10:42 AM
Edited May 24, 2010 at 10:43 AM

You would need to create a custom exception handler for this.   However, your exception policy would only contain one type of exception and that is the Exception type itself.  Your custom exception handler would be responsible for determining all the possible actions for every exception message you want to handle.  I'm not sure if that is a good practice but that's the only way I could think of since the exception block uses the exception type to determine which policies to apply. 

 

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@Avanade.com