Error handling in asp
by Nirmala[ Edit ] 2010-02-16 14:13:58
ASP pages are so easy to put together that sometimes developers have not thought through the problems associated with errors. Error handling can help your application to be more robust. I have often come across commercial sites written in ASP that fail to have any sort of error handling.
Types of Error
There are 3 main types of errors:
* Compile-time errors
These errors are usually in the syntax of the code and stop the ASP from compiling. You may have experienced this if you left the closing Next statement off of a "For" loop.
* Runtime errors
These happen when you try to execute the ASP page. For example, if you try setting a variable outside its allowed range.
* Logic errors
Logic errors are harder to detect. The problem lies within the structure of the code, and the computer cannot detect an error. These types require thorough testing before rolling out the application.
As compile-time errors are always trapped and logic errors are only found through thorough testing. This leaves us to worry only about runtime errors. These can stop the execution of your page and leave the user with a lot of non-user-friendly text on the screen.
Generally if an error is encountered in your .asp file, the processing of your script stops and an error message is returned to the browser. If you want to continue processing your page even if an error is encountered, include the following line at the beginning of your .asp file:
<% On Error Resume Next %>