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 Structured error handling statements

A program indicates that an error condition has occurred by executing a Throw statement. The statement "throws" an object of a type derived from System.Exception that provides information about the error that has occurred. If the expression does not evaluate to an instance of a type derived from System.Exception, then an error occurs at compile time. If at runtime the expression evaluates to Nothing, then a System.NullReferenceException object instance is thrown instead.

Structured error handling is done through a Try statement. Exceptions thrown by the Throw statement can be "caught" in a Try statement. Execution of a Try statement begins with the first statement in the try block. It is illegal to explicitly transfer execution into a try block except from a catch block.

A Throw statement may omit the expression within a catch block of a Try statement. In that case, the statement "rethrows" the current exception currently being handled within the catch block.

StructuredErrorStatement ::=
 ThrowStatement |
 TryStatement
ThrowStatement ::= Throw [ Expression ] StatementTerminator
TryStatement ::=
 Try StatementTerminator
 [ Block ]
 [ CatchStatement+ ]
 [ FinallyStatement ]
 End Try StatementTerminator