Mercurial > octave
diff src/toplev.cc @ 8011:3100283874d7
improve backtrace error messages
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 05 Aug 2008 23:09:32 -0400 |
parents | 0d607e8dbbfa |
children | b3e667f1ab4c |
line wrap: on
line diff
--- a/src/toplev.cc Tue Aug 05 12:14:33 2008 -0400 +++ b/src/toplev.cc Tue Aug 05 23:09:32 2008 -0400 @@ -473,6 +473,41 @@ } void +octave_call_stack::backtrace_error_message (void) const +{ + if (error_state > 0) + { + error_state = -1; + + error ("called from:"); + } + + if (! cs.empty ()) + { + const call_stack_elt& elt = cs.back (); + + octave_function *fcn = elt.fcn; + tree_statement *stmt = elt.stmt; + + std::string fcn_name = "?unknown?"; + + if (fcn) + { + fcn_name = fcn->fcn_file_name (); + + if (fcn_name.empty ()) + fcn_name = fcn->name (); + } + + int line = stmt ? stmt->line () : -1; + int column = stmt ? stmt->column () : -1; + + error (" %s at line %d, column %d", + fcn_name.c_str (), line, column); + } +} + +void recover_from_exception (void) { can_interrupt = true;