Mercurial > octave
changeset 27696:cf231bc5876f
improve error messages when executing slected code by F9 (bug #57205)
* octave-qscintilla.cc (contextmenu_run): only remove line x, column x
and following text in the first line of a multiline error message and
only if it belongs to the temporary file
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Fri, 15 Nov 2019 20:38:21 +0100 |
parents | cdb681adc85a |
children | 5e8891dceec7 |
files | libgui/src/m-editor/octave-qscintilla.cc |
diffstat | 1 files changed, 13 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/octave-qscintilla.cc Fri Nov 15 10:37:33 2019 -0500 +++ b/libgui/src/m-editor/octave-qscintilla.cc Fri Nov 15 20:38:21 2019 +0100 @@ -914,23 +914,28 @@ emit ctx_menu_run_finished_signal (show_dbg_file, tmp_file, tmp_hist, tmp_script); - // Drop line and column from error message - std::size_t line_pos = e.message ().find ("near line"); - std::string new_msg = e.message (); - if (line_pos != std::string::npos) + // New error message and error stack + QString new_msg = QString::fromStdString (e.message ()); + std::list<frame_info> stack = e.stack_info (); + + // Remove line and column from first line of error message only + // if it is related to the tmp itself, i.e. only if the + // the error stack size is 0 or 1 + if (stack.size () < 2) { - new_msg = e.message ().substr (0, line_pos); - new_msg.append ("near line 1, column 1"); + new_msg = new_msg.replace ( + QRegExp ("near line [^\n]*\n"), QString ("\n")); + new_msg = new_msg.replace ( + QRegExp ("near line [^\n]*$"), QString ("")); } // Drop first stack level, i.e. temporary function file - std::list<frame_info> stack = e.stack_info (); if (stack.size () > 0) stack.pop_back (); // New exception with updated message and stack octave::execution_exception ee (e.err_type (),e.identifier (), - new_msg, stack); + new_msg.toStdString (), stack); // Throw throw (ee);