Home  |  Latest News  |  Contribute  |  F.A.Q.  |  Account  |  Scripts | About
Search ASPNut:
 
ASP Reference
Server Variables
ASP Glossary
Related Sites

Free Components

HTML Reference
Web Colors
Entities
CSS Level 1
Encode/Decode
Glossary

Our Sponsors
ASP Nuke CMS
Free Auctions
PHP 5 Script
Funktastic Blog
ULost Directory
Team Task

 

 

 

 

 

 

 

 

 

 

 

 

On Error

The On Error statement allows you to create an error handler that will trap all runtime errors. This doesn't catch compile errors which occur before your script even begins running.

The most common form of this statement is On Error Resume Next which tells the script engine to Not throw an error and procede to the next statement. You can detect if the previous line has thrown an error by checking the Err.Number property.

For instance, if you do a mathematical calculation that results in a divide-by-zero error, this can be caught by an On Error handler. Also, any type of database query error that occurs when using the ADO library can be caught because it is considered a runtime error.

Const ZERO = 0
Dim fVar

On Error Resume Next
fVar = 10.0 / ZERO
If Err.Number <> 0 Then
    Response.Write "Error Occurred in fVar Calculation: " & Err.Description
    Response.Write "Error Number: " & Err.Number
End If
On Error Goto 0


As you can see in the sample code above, you terminate the error handler with the statement On Error Goto 0. This special command tells the script engine to resume normal error handling processing.

Orvado Technologies

ASP Nuke CMS
Free Open Source
Content Manager
HomeFix Boards
Home Remodeling
Message Boards

Contact Us | Contribute | About | Site Map



"The man who has no imagination has no wings." - Muhammad Ali

©2007 Orvado Technologies, All Rights Reserved
ASP Nut provides articles and reference documentation for Active Server Page developers.