Thursday, December 04, 2008

Thoughts on error handling in classic ASP

Most of our code base is written in classic ASP and VBScript. And, most of it was written without any sort of error logging. We've been coming to the realization that one of our applications definitely needs some sort of error logging, so I started doing some research.

I've wondered before about adding error logging and friendlier error messages for our other ASP applications, but didn't know of a simple way to do global error handling. But, while researching I found that it's easier than I had imagined.

The trick is to create an ASP page and set it as the default handler for 500;100 errors from IIS. You can use Server.GetLastError() to retrieve information for the last error. You also get to keep context information from the Request and other objects. So, after calling Server.GetLastError(), just log the relevant error and context info, send notification e-mails and display a friendly error message.

Speaking of friendly error messages, I think this error page from Southwest.com is a good example of simplicity and effectiveness:

Southwest.com error page

No comments:

Post a Comment