The format of the try statement is:
The execution moves to the catch section if an exception occurs in the try section. If without the catch section, execution moves to the next of the endtry.
When the execution reaches the catch or endtry without any exception, execution moves to the next of the endtry.
A keyword that indicates that it is an try statement and the start of an try section.
The format of the try section is:
Only one try section is required at the beginning of the try statement.
A keyword that indicates that the start of an catch section.
The format of the catch section is:
If an exception occurs in the try section, the statements in this section will be executed unconditionally.
When the execution reaches the endtry, the execution moves to the next to the endtry.
If an exception occurs again in the catch section, the exception is thrown to outside of the current try statement.
The catch section is optional. Only one can exist in an try statement.
If there is no catch section, an exception occurred in the try section will be considered handled unconditionally.
There is no scope for the entire try statement. Sections generate separate scopes.
When execution reaches the catch, a scope is generated. And, the reserved variable __error is defined.
__error is a variable of the error class. It will be initialized with an exception occurred in the try section.
The statements within a section are optional. You can place statements as many as you want.
It is a keyword that indicates the end of the try statement.
You can use the abbreviation "et" instead of "endtry". Note that "et" is also a keyword.
open method void someMethod()
ex.someMethod(); // It throws an exception.
string mess = __error.ExceptionData.Entity; // "exception"
An exception is thrown from the someMethod().
The exception is caught by the try statement, and the execution moves to the catch section.
When execution moves to the catch section, the reserved variable __error has stored the thrown exception.