Next: Continuation Lines, Previous: The unwind_protect Statement, Up: Statements [Contents][Index]
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. See Errors and Warnings, for more information about the
lasterr
and lasterror
functions.