manpagez: man pages & more
info octave
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

10.9 The try Statement

In addition to unwind_protect, Octave supports another limited form of exception handling.

The general 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 function lasterr to access the text of the message that would have been printed. This is the same as eval (try, catch) but it is more efficient since the commands do not need to be parsed each time the try and catch statements are evaluated. See section Errors and Warnings, for more information about the lasterr function.


© manpagez.com 2000-2024
Individual documents may contain additional copyright information.