Share via


JScript Run-time Errors

JScript run-time errors result when JScript script attempts to perform an action that the system cannot execute. JScript run-time errors occur when variable expressions are being evaluated during script execution and memory is being dynamically allocated.

Trapping Errors

Run-time errors can be trapped and examined by a JScript program. By enclosing the code that produces the error in a try block, any thrown error can be caught with a catch block. The errors that JScript throws are Error objects. JScript code can generate custom errors of any data type, including Error objects, by using the throw statement. A program can display the error number and message of a caught Error object to help identify the error. If an error is not caught, the script will terminate.

There are several ways to get help for a particular error message:

  • Look for the error number and message in the table of contents contained in the JScript Run-time Errors node.

  • Type the error number in the Look for box in the Index. The error number is in the format JSxxxx, where xxxx is the four-digit error code.

  • Type the error message in the Look for box in the Search. Remember that some error messages include words in single quotes. The quoted words refer to identifiers from the code and are not part of the error message. Do not include the quoted words as part of your search.

See Also

Concepts

JScript Syntax Errors

Reference

Error Object

try...catch...finally Statement

throw Statement