Friday 12 February 2010

Exception Handling in ASP.NET


This is a good article in how to exception handle efficiently in ASP.NET. It mentioned key pointers regarding: Page Level error capture, Application_Error method in Global.asax and other means of caputring errors across web applications.

The idea of error capture is to display a meaningful error message at each level.

For example, in an N-Tier world...

- Calling a database with invalid credentials may throw a "InvalidMethodCall" exception.
- In the BLL, this may be captured and re-thrown with regards to the method being called. I.e. "InvalidCallToAccounts"
- The user may then get (should get a) detailed error message and how to resolve this (any other options, try again links etc.) I.e. "Could not establish link to the accounts database. The credentials you have specified are invalid. Please try again..."

Here is the link
http://www.jankoatwarpspeed.com/post/2008/06/02/Exception-handling-best-practices-in-ASPNET-web-applications.aspx

No comments: