Exception Handling

  • Thread starter Thread starter Subramanian Iyer.NET
  • Start date Start date
S

Subramanian Iyer.NET

Hi,

Considering the scenario for handling exceptions in Web Application where we
have Presentation layer, Business layer and Data Access layer; if there any
exception is occurred in DAL, which is the best thing to do:

1. Not to catch the exception in DAL and let it pop up to the Application
level and let the Global.Application_Error event, log it to any source and
show. Let ASP.NET show custom error page provided in Web.Config file.

OR

2. To Catch Exception in DAL, Log the error using some Exception Handling
mechanism and Tranfer the control to another page using
Server.Transfer("ErrorPage.aspx");

Which one of the above 1 or 2 is the best way to handle exceptions?

Regards
Iyer
 
I'm personally of the opinion that you should only catch an exception if
you are expecting it and can recover gracefully from it. Otherwise it
should bubble its way all the way to the top of the call stack. I have a
logic in Application_OnError in global.asax.cs that logs any unhandled
exceptions to the Event Log and a database then displays a friendly
message to the user as well as shows debug information to specific users
inside the organization based on IP.

Hope that helps,
Rob Epstein
Sr Developer
Auctionworks, Inc.
"Nothing's impossible until proven so." - Me
 
Back
Top