octave: The try Statement
10.9 The try Statement
======================
The original form of a ‘try’ block looks like this:
try
BODY
catch
CLEANUP
end_try_catch
where BODY and CLEANUP are both optional and may contain any Octave
expressions or commands. The statements in CLEANUP are only executed if
an error occurs in BODY.
No warnings or error messages are printed while BODY is executing.
If an error does occur during the execution of BODY, CLEANUP can use the
functions ‘lasterr’ or ‘lasterror’ to access the text of the message
that would have been printed, as well as its identifier. The
alternative form,
try
BODY
catch ERR
CLEANUP
end_try_catch
will automatically store the output of ‘lasterror’ in the structure ERR.
Errors and Warnings, for more information about the ‘lasterr’
and ‘lasterror’ functions.