Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Web
Expertise: Intermediate
Jul 26, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Employ Error Handling With ASP

Without error handling, any ASP (Active Server Pages) error is fatal as it will stop the execution of your page. To bullet proof your ASP, you can add error handlers. In ASP, you generally don't need "global" error handling. However, there are probably some small segments of your code, such as a function or two, where you suspect runtime errors are probable. To start the error handling, use "on error resume next". This statement basically promises that an error will not terminate execution. Check the error number to see if any errors have occurred and take the appropriate action. Finally, to turn off error handling, use "on error goto 0". Using this technique around the trouble spots in your code can help you avoid unexpected runtime errors.

on error resume next
Response.Write 1/0
if err.number <> 0 then
  response.write "Let's handle the error!"
end if
on error goto 0

Response.Write 1/0

William Wen
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date