Mercurial > octave
changeset 33247:55e1412aca35
call error instead of abort in panic_impossible, panic_if, and panic_unless
* error.cc (error_system::vpanic): Call ::verror to issue message and
throw error instead of printing message directly to std::error and
calling abort.
* panic.h: Fix comment.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 25 Mar 2024 00:43:53 -0400 |
parents | 399be7cc310f |
children | 7f73e4805a1f |
files | libinterp/corefcn/error.cc libinterp/corefcn/panic.h |
diffstat | 2 files changed, 10 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/error.cc Sat Mar 23 13:54:13 2024 -0400 +++ b/libinterp/corefcn/error.cc Mon Mar 25 00:43:53 2024 -0400 @@ -633,12 +633,15 @@ void error_system::vpanic (const char *fmt, va_list args) { - // Is there any point in trying to write the panic message to the - // diary? + // Earlier versions of Octave printed a message directly to std::cerr + // and called abort. That might be acceptable behavior for some + // programs but for an interactive application like Octave, aborting + // the entire program when an internal programming error has been + // detected seems unnecessary and certainly provides a much worse user + // experience than simply generating an ordinary error message and + // attempting to return to the command prompt. - std::cerr << "panic: " << format_message (fmt, args) << std::endl; - - abort (); + ::verror (fmt, args); } void
--- a/libinterp/corefcn/panic.h Sat Mar 23 13:54:13 2024 -0400 +++ b/libinterp/corefcn/panic.h Mon Mar 25 00:43:53 2024 -0400 @@ -38,8 +38,8 @@ extern OCTINTERP_API void panic (const char *fmt, ...); // To allow the __FILE__ and __LINE__ macros to work as expected, the -// panic_impossible, panic_if, panic_unless, error_impossible, error_if, -// and error_unless symbols must be defined as macros. +// panic_impossible, panic_if, and panic_unless symbols must be defined +// as macros. #define panic_impossible() \ ::panic ("impossible state reached in file '%s' at line %d", __FILE__, __LINE__)