O'Reilly logo

VBScript in a Nutshell, 2nd Edition by Ron Petrusha, Matt Childs, Paul Lomax

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 the On 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required