September 14, 2002 - Throwing Exceptions
September 14, 2002|
Tips: September 2002
Yehuda Shiran, Ph.D.
catchblock associated with the
tryblock where the error occurred. In this case, use the
throwstatement to re-throw the error to higher-level error handling. A
try...catch...finallystatement may be nested within a higher-level
trystatement. When you throw an exception from a lower-level
catchblock, it will be caught by the higher level
catchblock. The syntax is very simple:
exceptionis any expression and is required. It can be a string or an
Errorobject. The exception value is simply passed as a parameter to the
catchblock. If the throw statement is inside a
tryblock, the exception value is passed to the corresponding same-level
catchblock. If the
throwstatement is inside a
catchblock, the exception value is passed to the higher-level
catchblock, if one exists.
To learn more about exception handling, go to Column 118, JScript .NET, Part XII: Exception Handling.