Exception Handling

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Subramanian Iyer.NET

    #1

    Exception Handling

    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.Applicat ion_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.asp x");

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

    Regards
    Iyer


  • Rob Epstein

    #2
    Re: Exception Handling

    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_OnE rror 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

    Subramanian Iyer.NET wrote:
    [color=blue]
    > 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.Applicat ion_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.asp x");
    >
    > Which one of the above 1 or 2 is the best way to handle exceptions?
    >
    > Regards
    > Iyer
    >
    >[/color]

    Comment

    Working...