Error messages help you troubleshoot unexpected results or behaviors in scripts.
Syntax errors occur when JScript statements violate syntax rules. Run-time errors occur during script execution.
JScript syntax errors result when the structure of JScript statements violates one or more of the grammatical rules of the JScript scripting language. JScript syntax errors occur during program compilation, before the program starts execution.
JScript run-time errors occur when a 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.
Run-time errors can be caught and examined by a JScript program. If you enclose the code that produces the error in a try block, you can catch it with a catch block.
The errors that JScript throws are Error objects. A program can display the error number and message of a caught Error object to help you identify the error.
If an error is not caught, the script will terminate.
JScript code can generate custom errors of any data type, including Error objects, by using the throw statement.