Forum Moderators: open

Message Too Old, No Replies

ASP-Best Error Handling Method

custom error page, individual error logging?

         

ohfiddlesticks

10:03 pm on Mar 11, 2005 (gmt 0)

10+ Year Member



I'm trying to improve the error handling on my ASP (not ASP.NET) and MSSQL Server driven site. I read several articles on techniques and am not sure which one to use where.

So far, I have tried making a custom 500_100 error page for IIS that collects ASP error info using Server.GetLastError(), emails it to me, and displays a generic error message to the user. It seems to work great, and is the simplest way to go. For this I don't use "On Error Resume Next" in the pages, I just let the errors occur and go to my custom page.

I have also tried the method of using "On Error Resume Next" and including an error handling script on each page. I check for errors using "If Err.Number<>0" and run a function that logs and clears the errors as they occur. I put the error checking line after all calls to the database. This seems cumbersome to add to all the pages and adding it to every possible place an ASP error of any kind could occur is alot of work. It also doesn't let me get more detailed information about the error like what line it was on.

The site is a small ecommerce one and the types of pages I am worried about are things like: search,product info, shopping cart, checkout, and a contact form. Basically anything that runs a script to access the database,work with files, send e-mails, etc.

I'm worried that if I let errors halt execution and go to my custom error page that some small insignificant error could make the site unusable until I fix it. But...if I resume execution after errors then it could do more harm than good,produce unexpected results, and confuse the user. I don't anticipate many errors, but you never know what can happen....servers go down, users do really weird unexplainable stuff, or I might make a stupid mistake whilst attempting to program at 2am :).

Any advice or links to articles about this would be very much appreciated.

mattglet

12:41 am on Mar 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My opinion, from my experiences:

I too once used On Error Resume Next... Never again.

I now make my own custom 500 pages, with database logging, email sending, alerts out the wazoo. When you first roll out new code, sure you may find a 500 here or there, but they are quickly resolved. The custom page is much much more easy to handle, and is more "pretty" to the end user. Like you said, error resuming can produce some crazy results, which could also open up a security hole in your site. And yes, you have to put an error checker on every page if you choose to resume. Too bloated for my liking.

I say go the custom route, and don't look back.