Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Thinking a system to handle errors in my app

Status
Not open for further replies.

ericnet

Programmer
Mar 29, 2006
106
Hello,

I want to implement a system to handle all possible errors in my ASP.NET VB application. Now, in each aspx page, I have a Try...Catch block that handles the possibility of error while a code to store user activity is executed.


My plan is:

Every time an error happens in those Try...Catch blocks, register an error in the database, storing Error Message, Inner Exception, Source, Help Link, Session Number (stored in an in-memory cookie), and User Number (stored in a permanent cookie). While this error registration is done, the user will see the page normally, as is (without any error), but if an unexpected error happens during this error registration, I want to show a friendly general error page.

Ok, until here I know how to do it (or I would), but the part I don’ t know how to do it is register the general error in the database. I mean, store the same information I mentioned, but for that general error, so, Error Message, Inner Exception, Source, Help Link, Session Number (stored in an in-memory cookie), and User Number (stored in a permanent cookie). Where I have to put this code? In the web.config file? Or in the global.asax.vb file? And also, Is the idea I explained a good way to handle errors?
(I program all my code in line, without any IDE)

Experienced opinions will be welcomed

Thank you
 
I'd use the Application_Error event (in the Global.asax file) to handle any unexpected errors and then use the customErrors tag (in the web.config file) to redirect the users to your "friendly" error page. If you go down this route, you'll want to check out the Server.GetLastError.GetBaseException() method in order to get a reference to the error.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Hi ca8msm,

Thanks to answer.
After read an excellent article titled "Exception Management Architecture Guide" my general idea about handling exceptions has changed.

In my opinion, when designing a system to handle .NET application exceptions, and your infrastructure does not allow the use of EIF (Enterprise Instrumentation Framework) and/or a beautiful Monitoring application, the most important things you have to be clear are:

1- Register the exception somewhere to make information permanent, and easily can review and analyze all what happened.
2- Do quick and effective notifications so that can solve the problem as soon as possible.

About register the exception the best place is the Windows Event Log file.
And about notifications the best choice is sending mails using SMTP.

For me, those are the best choices for a marketplace startup with limited resources and development time

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top