NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

9.11.1.2 Catch blocks

If an exception occurs while processing the try block, each Catch statement is examined in textual order to determine if it handles the exception. The identifier specified in a catch clause represents the exception that has been thrown. The identifier is considered to be declared within the catch block's locals declaration space.

A Catch clause with no identifier will catch all exceptions derived from System.Exception. A catch clause with an identifier will only catch exceptions whose types are the same as or derived from the type of the identifier. The type must be System.Exception or a type derived from System.Exception. A catch clause with a When clause will only catch exceptions when the expression evaluates to True.The type of the expression must be implicitly convertible to Boolean. A when clause is only applied after checking the type of the exception and the expression may refer to the identifier representing the exception.

If a catch clause handles the exception, then execution transfers to the catch block. At the end of the catch block, execution transfers to the first statement following the Try statement. The Try statement will not handle any exceptions thrown in a catch block. If no catch clause handles the exception, execution transfers to a location determined by the NGWS Runtime. It is illegal to explicitly transfer execution into a catch block.

CatchStatement ::=
 Catch [ Identifier As TypeName ] [ When BooleanExpression ] StatementTerminator
 [ Block ]