| www.delorie.com/gnu/docs/octave/octave_87.html | search |
![]() Buy GNU books! | |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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 access the text of the message that would have been
printed in the builtin constant __error_text__. This is the same
as eval (try, catch) (which may now also use
__error_text__) 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. Error Handling, for more information about the
__error_text__ variable.
Octave's try block is a very limited variation on the Lisp condition-case form (limited because it cannot handle different classes of errors separately). Perhaps at some point Octave can have some sort of classification of errors and try-catch can be improved to be as powerful as condition-case in Lisp.
| webmaster donations bookstore | delorie software privacy |
| Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |