Error Hanling in .NET

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I am starting to develop a large 4 tier ASP.NET application.

I have looked at using the Enterprise Application Blocks for Exception
Management.

In all of our Methods / Functions we have try catch blocks.

In my catch block I rethrow the Exception.

Where and when should I log this Exception.

Should I let the exception bubble up to the Application_OnError routine in
the global.asax and log the Exception in here by using the ExceptionManager
of the ExceptionManagement Block.

To summarise-:

I want to catch all exceptions and log them and redirect the user to a user
friendly page which will indicate that an error has occured.
 
Not using this block, but if you do nothing special in response to this
exception, I would just let it bubble so that it is handled by
Application_OnError.
 
Is this good practice?

How should I handle the exception when it gets to the Application_Error in
the global.asax?

Can I log it to the Event Log from here? How?
 
Server.GetLastError() allows to get the exception.

Best practices is what makes sense. What do you do exactly ? Do you release
resources ? This is where it could be still usefull to have a try block with
a finally clause as you know at this level whihc resources should be
disposed. If you do nothing else than rethrowing what is the benefit ?
 
Back
Top