- publishing free software manuals
GNU Octave Manual Version 3
by John W. Eaton, David Bateman, Søren Hauberg
Paperback (6"x9"), 568 pages
ISBN 095461206X
RRP £24.95 ($39.95)

Get a printed copy>>>

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:


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 12 Errors and Warnings, for more information about the lasterr function.

ISBN 095461206XGNU Octave Manual Version 3See the print edition