Name
On Error Statement
Syntax
On Error Resume Next On Error Goto 0
Description
Enables or disables error handling within a procedure. If you
don’t use an On
Error
statement in your procedure, or if
you have explicitly switched off error handling, the VBScript
runtime engine handles the error automatically. First, it displays a
dialog containing the standard text of the error message, something
many users are likely to find incomprehensible. Second, it
terminates the application, so any error that occurs in the
procedure produces a fatal runtime error.
Rules at a Glance
When a runtime error occurs in the routine in which the
On
Error
Resume
Next
statement occurs, program execution continues with the program line following the line that generated the error. This means that, if you want to handle an error, this line following the line that generated the error should call or include an inline error-handling routine.When a runtime error occurs in any routine called by the routine in which the
On Error Resume Next
statement occurs, or by its subroutines, program execution returns to the statement immediately after the subroutine call in the routine containing theOn
Error
Resume
Next
statement.When used in an ASP page for IIS 5.0,
On
Error
Resume
Next
disables ASP’s own error handling.You disable error handling by using the
On
Error
Goto
0
statement.
Programming Tips and Gotchas
If you have no error handling in your procedure, the VBScript runtime engine traces back through the call stack until ...
Get VBScript in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.