try — beginning of try block in try-catch control instruction
try statements catch statements end
The try
-catch
control instruction can be used
to manage codes that could possibly generate errors.
When a try
-catch
control instruction is
executed, normally only the statements between the try
and
catch
keywords are executed. However, if an error occurs
during execution of any of these statements, the error is recorded, the
remaining statements up to the catch
keyword
are skipped and the statements between the catch
and
end
keywords are executed using the default error handling
mode (see: errcatch.
The recorded error can be retreived using the lasterror function.
The catch
statements as well as the catch
keyword can be omitted if no alternative statements are given.
Note that one can also use the execstr function with
'errcatch'
argument for error handling. This can be
particularily useful for handling syntactical errors.