Last post Sep 10, 2007 01:28 AM by ghinx
Sep 07, 2007 02:20 PM|redwing19|LINK
Man, I've already spent a couple days looking into this and haven't got very far...
What is the proper way to use the Exception Handling application block?
It looks like you setup various Exception Policies, and those policies can handle exceptions in different ways. So, for example, if you wanted to setup a policy dealing with Data Access, you'd create a DataAccess Exception Policy, add the type of Exceptions
you want to handle a certain way, and then in your code write:
// DataAccess code that could throw an error
catch (Exception ex)
bool rethrow = ExceptionPolicy.HandleException(ex, "DataAccess Exception Policy");
And then based on what handlers you have defined for the various exceptions for that policy in the Configuration Tool, the exception can be handled a variety of ways.
Is this correct?
You'd still have to add the try...catch block everywhere in your code though, right?
Sep 10, 2007 01:28 AM|ghinx|LINK
Hi, i've havent explored everything available through the ApplicationBlock, but ill post my 2 cents worth.
Yes you are right, you still need to add the try... catch block around codes where there is a possible exception
'you could use the method below to log the exception into eventviewer
add some configuration settings in your web config file.
You probably want to setup your own class to handle exceptions. Use this class to handle exceptions caught in the try catch.... block. if you wanted to change the way you handle exceptions
later on you only needed to change it in one place.
hope this helps cheers.