This project is read-only.
This is an application providing much useful contributes and extensions to MS EntLib.

Exception Handling


EntLib EHAB (Exception Handling Application Block) is a policy driven exception handling framework, and the exception policy is complete based on exception type. Such an exception type based policy is the biggest limitation of EHAB, which make us can only perform the same actions to handle the same type of exceptions. E.G. SqlException is always thrown when we perform data accessing against SQL Server, regardless of connection failure or stored procedure execution error. We cannot define more appropriate policy based on the concrete data access exception scenario. FilterableHandler makes it possible to define exception policy of fine granularity.

FilterableHandler is essentially an exception handler, which implements IExceptionHandler. However, it is not a general exception handler. In fact, FilterableHandler will never perform concrete exception handling action, but it can be used allocate appropriate exception handlers to handle the thrown exception based on a particular ExceptionFilter, which filters the thrown exception with some filter condition and finally deliver the exception to target exception handler group. We can define different ExceptionFilter by implementing the IExceptionFilter interface, whose definition is illustrated in the following code snippet. The return value of the Match method indicates whether the given exception matches the current filter.
public interface IExceptionFilter
    bool Match(Exception ex);

As aforementioned, FilterableHandler is just an exception handler, so we just need to put the exception policy controlled by FilterableHandler in its specific configuration. The following XML snippet illustrates the configuration structure specific to FilterableHandler.
    <add name="filter1" type="filterFullTypeName, AssemblyName" .../>
    <add name="filter2" type="filterFullTypeName, AssemblyName" .../>
    <add name="filter3" type="filterFullTypeName, AssemblyName" .../>
     <add name="filterEntry1" filter="filter1" priority = "2">
             <add name="handler1" type="handlerFullTypeName, AssemblyName" .../>
             <add name="handler2" type="handlerFullTypeName, AssemblyName" .../>
             <add name="handler3" type="handlerFullTypeName, AssemblyName" .../>
   <add name="filterEntry2" filter="filter2" priority = "1">
             <add name="handler4" type="handlerFullTypeName, AssemblyName"  .../>
             <add name="handler5" type="handlerFullTypeName, AssemblyName"  .../>
             <add name="handler6" type="handlerFullTypeName, AssemblyName"  .../>
   <add name="filterEntry3" filter="filter3" priority = "1">
             <add name="handler7" type="handlerFullTypeName, AssemblyName" .../>
             <add name="handler8" type="handlerFullTypeName, AssemblyName" .../>
             <add name="handler9" type="handlerFullTypeName, AssemblyName" .../>

Last edited Sep 27, 2011 at 1:46 PM by Artech, version 15