Error Hanling in .NET

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.
 
P

Patrice

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.
 
G

Guest

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?
 
P

Patrice

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 ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top