throw
Summary
Generates an error condition that can be handled by a try…catch…finally statement.
Syntax
throw exception
Examples
The following example throws an error inside a try block, and it is caught in the catch block.
try {
throw new Error(200, "x equals zero");
}
catch (e) {
document.write(e.message);
}
// Output: x equals zero.
Remarks
The required exception argument can be any expression.
See also
Other articles
Attributions
Microsoft Developer Network: Article