Layered Exception

Topics: Exception Handling Application Block, General discussion, Logging Application Block
Jul 30, 2013 at 5:12 AM
Edited Jul 30, 2013 at 5:13 AM
Hi all..

I'm new in Development environment.I want Handle and Store the Exception in Database.

In My project 4 layers available.(DA,BL,R,F).I handle the exceptions in 4 layers.


I want handle the error in layer wise.any error occurred in any one layer that error is not throwing another layer.

How to do in Enterprise library?
Jul 31, 2013 at 6:34 AM
In general, the way to do what you want is to create an ExceptionPolicy (perhaps one for each layer) and add a Logging Exception Handler. The logging handler would log to a Database Trace Listener. If you want to swallow exceptions you can do that by setting the Post handling action to "None".

For Enterprise Library 6, you can read the chapter on Exception Handling in the Developer's Guide. For Enterprise Library 5, you can read Chapter 3 of the Developer's Guide. The Hands on Labs provide good, practical examples which you can modify to try different scenarios (for example there is an example on Logging Exceptions).

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Aug 9, 2013 at 9:34 AM
Hi ,..

I add the Exception policy (perhaps one for each layer) and add the Logging handler.

What I Exception Type ?
Aug 9, 2013 at 5:54 PM
I'm not sure I understand your question; can you be more specific? Are you asking what exception type to use in the Exception Policy? If so, that's up to you -- it depends on what behavior you want. If the policy handles System.Exception then it will apply to all exceptions.

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to