Mercurial > octave-nkf
diff libcruft/misc/quit.cc @ 7481:78f3811155f7
use exceptions in liboctave error handler
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 14 Feb 2008 17:14:23 -0500 |
parents | a1dbe9d80eee |
children | eb63fbe60fab |
line wrap: on
line diff
--- a/libcruft/misc/quit.cc Wed Feb 13 00:00:33 2008 -0500 +++ b/libcruft/misc/quit.cc Thu Feb 14 17:14:23 2008 -0500 @@ -58,14 +58,49 @@ } void +octave_throw_execution_exception (void) +{ + // FIXME -- would a hook function be useful here? + + octave_exception_state = octave_exec_exception; + + throw octave_execution_exception (); +} + +void octave_throw_bad_alloc (void) { if (octave_bad_alloc_hook) octave_bad_alloc_hook (); + octave_exception_state = octave_alloc_exception; + throw std::bad_alloc (); } +void +octave_rethrow_exception (void) +{ + if (octave_interrupt_state) + octave_throw_interrupt_exception (); + else + { + switch (octave_exception_state) + { + case octave_exec_exception: + octave_throw_execution_exception (); + break; + + case octave_alloc_exception: + octave_throw_bad_alloc (); + break; + + default: + break; + } + } +} + /* ;;; Local Variables: *** ;;; mode: C++ ***