annotate liboctave/util/quit.cc @ 27471:fd32c1a9b1bd

revamp error handling In "error" and similar functions that ultimately call it, simply throw an exception that contains information about the error (message, id, stack info) instead of printing an error message immediately and then throwing an exception. The new approach is more flexible and sllows for some simplification of the error message routines as they no longer need feedback from the interpreter to know when to display or buffer messages. It is now the responsibility of any code that catches an execution exception to determine whether and when to display error messages. * quit.h, quit.cc (class frame_info): New class. (execution_exception::m_err_type, execution_exception::m_id, execution_exception::m_message, execution_exception::m_stack_info): New data members. (class execution_exception): Store error type, message, id, and stack info. Provide methods setting and accessing data as needed and for generating stack trace message from stack info. (execution_exception::m_stack_trace): Delete data member. execution_exception::set_stack_trace): Delete method. (execution_exception::set_err_type, execution_exception::err_type, execution_exception::stack_trace, execution_exception::set_identifier, execution_exception::identifier, execution_exception::message, execution_exception::set_stack_info, execution_exception::display): New methods. * call-stack.cc, call-stack.h (call_stack::backtrace_info): New functions. * oct-parse.yy (maybe_print_last_error_message): Delete function and all uses. * pt-eval.h, pt-eval.cc (tree_evaluator::backtrace_info, tree_evaluator::backtrace_message): New functions. (tree_evaluator::backtrace): Now const. (tree_evaluator::visit_unwind_protect_command, tree_evaluator::do_unwind_protect_cleanup_code, tree_evaluator::visit_try_catch_command, tree_evaluator::evalin, tree_evaluator::eval, tree_evaluator::repl, debugger::repl): Save current exception info. * interpreter.h, interpreter.cc (interpreter::handle_exception): New function. Use it in place of direct calls to error_system::save_exception, error_system::display_exception (or execution_exception::display) and interpreter::recover_from_exception, so that we have uniform behavior when responding to an execution exception. * error.h, error.cc (error_system::m_buffer_error_messages, error_system::m_discard_error_messages, error_system::m_in_try_catch): Delete data members and associated functions. Remove all uses. Because the error system no longer displays messages immediately, it does not need to track whether to discard or buffer error messages or know whether error and warning functions are invoked inside of try-catch blocks. Everywhere that catches execution_exceptions must now handle saving the exception state (for lasterror) and displaying the error message and traceback as needed. (): Delete functions and all uses. (error_stack_frame): Delete struct definition. (verror, vpr_where, pr_where_internal, pr_where, maybe_enter_debugger, make_execution_exception, vmessage_with_id, message_with_id, error_system::maybe_enter_debugger, reset_error_handler, error_system::reset): Delete functions and all uses. (error_system::try_option): Delete enum and all uses. (vusage, error_1, error_system::vwarning, error_system::rethrow_error, error_system::interpreter_try): Simplify. (format_message, make_stack_map, error_system::throw_error, error_system::save_exception, error_system::display_exception): New functions. (Ferror): Update for error_system changes.
author John W. Eaton <jwe@octave.org>
date Fri, 04 Oct 2019 01:15:13 -0400
parents 00f796120a6d
children 63b417917f5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
1 /*
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
2
26376
00f796120a6d maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
3 Copyright (C) 2002-2019 John W. Eaton
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
4
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
6
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24444
diff changeset
7 Octave is free software: you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
8 under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24444
diff changeset
9 the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
10 (at your option) any later version.
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
11
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
12 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
13 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
15 GNU General Public License for more details.
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
16
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
18 along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24444
diff changeset
19 <https://www.gnu.org/licenses/>.
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
20
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
21 */
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
22
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
23 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21202
diff changeset
24 # include "config.h"
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
25 #endif
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
26
4154
f10865750046 [project @ 2002-11-07 15:31:42 by jwe]
jwe
parents: 4153
diff changeset
27 #include <cstring>
f10865750046 [project @ 2002-11-07 15:31:42 by jwe]
jwe
parents: 4153
diff changeset
28
27471
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
29 #include <ostream>
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
30 #include <sstream>
4180
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4154
diff changeset
31 #include <new>
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4154
diff changeset
32
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
33 #include "quit.h"
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
34
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23426
diff changeset
35 void (*octave_signal_hook) (void) = nullptr;
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23426
diff changeset
36 void (*octave_interrupt_hook) (void) = nullptr;
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23426
diff changeset
37 void (*octave_bad_alloc_hook) (void) = nullptr;
4429
c1f6200b5f0e [project @ 2003-06-17 04:36:08 by jwe]
jwe
parents: 4270
diff changeset
38
27471
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
39 namespace octave
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
40 {
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
41 std::string execution_exception::stack_trace (void) const
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
42 {
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
43 size_t nframes = m_stack_info.size ();
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
44
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
45 if (nframes == 0)
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
46 return std::string ();
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
47
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
48 std::ostringstream buf;
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
49
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
50 buf << "error: called from\n";
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
51
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
52 for (const auto& frm : m_stack_info)
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
53 {
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
54 buf << " " << frm.fcn_name ();
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
55
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
56 int line = frm.line ();
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
57
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
58 if (line > 0)
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
59 {
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
60 buf << " at line " << line;
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
61
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
62 int column = frm.column ();
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
63
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
64 if (column > 0)
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
65 buf << " column " << column;
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
66 }
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
67
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
68 buf << "\n";
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
69 }
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
70
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
71 return buf.str ();
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
72 }
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
73
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
74 void execution_exception::display (std::ostream& os) const
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
75 {
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
76 if (! m_message.empty ())
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
77 {
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
78 os << m_err_type << ": " << m_message;
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
79
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
80 if (m_message.back () != '\n')
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
81 {
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
82 os << "\n";
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
83
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
84 std::string st = stack_trace ();
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
85
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
86 if (! st.empty ())
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
87 os << st;
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
88 }
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
89 }
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
90 }
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
91 }
fd32c1a9b1bd revamp error handling
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
92
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
93 void
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 4571
diff changeset
94 octave_handle_signal (void)
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 4571
diff changeset
95 {
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 4571
diff changeset
96 if (octave_signal_hook)
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 4571
diff changeset
97 octave_signal_hook ();
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 4571
diff changeset
98
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 4571
diff changeset
99 if (octave_interrupt_state > 0)
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 4571
diff changeset
100 {
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 4571
diff changeset
101 octave_interrupt_state = -1;
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 4571
diff changeset
102 octave_throw_interrupt_exception ();
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 4571
diff changeset
103 }
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 4571
diff changeset
104 }
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 4571
diff changeset
105
23245
aaf5ac82979d * quit.cc (clean_up_and_exit): Don't declare definition extern.
John W. Eaton <jwe@octave.org>
parents: 23238
diff changeset
106 void
23087
9f406f0b36da rework clean_up_and_exit (bug #50068)
John W. Eaton <jwe@octave.org>
parents: 23084
diff changeset
107 clean_up_and_exit (int exit_status, bool /* safe_to_return */)
22094
9203833cab7d move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
108 {
23087
9f406f0b36da rework clean_up_and_exit (bug #50068)
John W. Eaton <jwe@octave.org>
parents: 23084
diff changeset
109 exit (exit_status);
22094
9203833cab7d move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
110 }
9203833cab7d move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
111
5142
0f9108f298ab [project @ 2005-02-12 02:29:34 by jwe]
jwe
parents: 4571
diff changeset
112 void
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
113 octave_throw_interrupt_exception (void)
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
114 {
4429
c1f6200b5f0e [project @ 2003-06-17 04:36:08 by jwe]
jwe
parents: 4270
diff changeset
115 if (octave_interrupt_hook)
c1f6200b5f0e [project @ 2003-06-17 04:36:08 by jwe]
jwe
parents: 4270
diff changeset
116 octave_interrupt_hook ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
117
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
118 throw octave::interrupt_exception ();
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
119 }
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents:
diff changeset
120
4180
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4154
diff changeset
121 void
7481
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
122 octave_throw_execution_exception (void)
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
123 {
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
124 // FIXME: would a hook function be useful here?
7481
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
125
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
126 octave_exception_state = octave_exec_exception;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
127
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
128 throw octave::execution_exception ();
7481
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
129 }
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
130
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
131 void
4180
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4154
diff changeset
132 octave_throw_bad_alloc (void)
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4154
diff changeset
133 {
4429
c1f6200b5f0e [project @ 2003-06-17 04:36:08 by jwe]
jwe
parents: 4270
diff changeset
134 if (octave_bad_alloc_hook)
c1f6200b5f0e [project @ 2003-06-17 04:36:08 by jwe]
jwe
parents: 4270
diff changeset
135 octave_bad_alloc_hook ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
136
7481
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
137 octave_exception_state = octave_alloc_exception;
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
138
4181
dd2abf428f5d [project @ 2002-11-15 18:33:41 by jwe]
jwe
parents: 4180
diff changeset
139 throw std::bad_alloc ();
4180
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4154
diff changeset
140 }
84fe3ca3a246 [project @ 2002-11-15 04:47:01 by jwe]
jwe
parents: 4154
diff changeset
141
7481
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
142 void
23238
3de5efeffb86 Eliminate compilation warnings related to clean_up_and_exit fcn (bug #50265).
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
143 octave_throw_exit_exception (int exit_status, int safe_to_return)
3de5efeffb86 Eliminate compilation warnings related to clean_up_and_exit fcn (bug #50265).
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
144 {
3de5efeffb86 Eliminate compilation warnings related to clean_up_and_exit fcn (bug #50265).
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
145 octave_exception_state = octave_quit_exception;
3de5efeffb86 Eliminate compilation warnings related to clean_up_and_exit fcn (bug #50265).
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
146
23398
d4ef04757ead eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents: 23245
diff changeset
147 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
24444
53ca76c5cc8d maint: Indent pragmas as other preprocessor directives.
John W. Eaton <jwe@octave.org>
parents: 23795
diff changeset
148 # pragma GCC diagnostic push
53ca76c5cc8d maint: Indent pragmas as other preprocessor directives.
John W. Eaton <jwe@octave.org>
parents: 23795
diff changeset
149 # pragma GCC diagnostic ignored "-Wdeprecated-declarations"
23398
d4ef04757ead eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents: 23245
diff changeset
150 #endif
d4ef04757ead eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents: 23245
diff changeset
151
25147
5960fd1b56f1 remove C++ functions, classes, and typdefs deprecated in version 4.2
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
152 throw octave::exit_exception (exit_status, safe_to_return);
23398
d4ef04757ead eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents: 23245
diff changeset
153
d4ef04757ead eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents: 23245
diff changeset
154 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
24444
53ca76c5cc8d maint: Indent pragmas as other preprocessor directives.
John W. Eaton <jwe@octave.org>
parents: 23795
diff changeset
155 # pragma GCC diagnostic pop
23398
d4ef04757ead eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents: 23245
diff changeset
156 #endif
23238
3de5efeffb86 Eliminate compilation warnings related to clean_up_and_exit fcn (bug #50265).
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
157 }
3de5efeffb86 Eliminate compilation warnings related to clean_up_and_exit fcn (bug #50265).
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
158
3de5efeffb86 Eliminate compilation warnings related to clean_up_and_exit fcn (bug #50265).
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
159 void
7481
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
160 octave_rethrow_exception (void)
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
161 {
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
162 if (octave_interrupt_state)
10069
c670c8be7f93 fix incorrect octave_interrupt_state escaped from liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9933
diff changeset
163 {
c670c8be7f93 fix incorrect octave_interrupt_state escaped from liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9933
diff changeset
164 octave_interrupt_state = -1;
c670c8be7f93 fix incorrect octave_interrupt_state escaped from liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9933
diff changeset
165 octave_throw_interrupt_exception ();
c670c8be7f93 fix incorrect octave_interrupt_state escaped from liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9933
diff changeset
166 }
7481
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
167 else
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
168 {
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
169 switch (octave_exception_state)
10164
085d4e025155 libcruft/misc/quit.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10069
diff changeset
170 {
085d4e025155 libcruft/misc/quit.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10069
diff changeset
171 case octave_exec_exception:
085d4e025155 libcruft/misc/quit.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10069
diff changeset
172 octave_throw_execution_exception ();
085d4e025155 libcruft/misc/quit.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10069
diff changeset
173 break;
7481
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
174
10164
085d4e025155 libcruft/misc/quit.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10069
diff changeset
175 case octave_alloc_exception:
085d4e025155 libcruft/misc/quit.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10069
diff changeset
176 octave_throw_bad_alloc ();
085d4e025155 libcruft/misc/quit.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10069
diff changeset
177 break;
7481
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
178
23398
d4ef04757ead eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents: 23245
diff changeset
179 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
24444
53ca76c5cc8d maint: Indent pragmas as other preprocessor directives.
John W. Eaton <jwe@octave.org>
parents: 23795
diff changeset
180 # pragma GCC diagnostic push
53ca76c5cc8d maint: Indent pragmas as other preprocessor directives.
John W. Eaton <jwe@octave.org>
parents: 23795
diff changeset
181 # pragma GCC diagnostic ignored "-Wdeprecated-declarations"
23398
d4ef04757ead eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents: 23245
diff changeset
182 #endif
d4ef04757ead eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents: 23245
diff changeset
183
22094
9203833cab7d move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
184 case octave_quit_exception:
23238
3de5efeffb86 Eliminate compilation warnings related to clean_up_and_exit fcn (bug #50265).
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
185 octave_throw_exit_exception (octave_exit_exception_status,
3de5efeffb86 Eliminate compilation warnings related to clean_up_and_exit fcn (bug #50265).
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
186 octave_exit_exception_safe_to_return);
22094
9203833cab7d move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
187 break;
9203833cab7d move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
188
23398
d4ef04757ead eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents: 23245
diff changeset
189 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
24444
53ca76c5cc8d maint: Indent pragmas as other preprocessor directives.
John W. Eaton <jwe@octave.org>
parents: 23795
diff changeset
190 # pragma GCC diagnostic pop
23398
d4ef04757ead eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents: 23245
diff changeset
191 #endif
d4ef04757ead eliminate some compiler warnings
John W. Eaton <jwe@octave.org>
parents: 23245
diff changeset
192
10164
085d4e025155 libcruft/misc/quit.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10069
diff changeset
193 default:
085d4e025155 libcruft/misc/quit.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10069
diff changeset
194 break;
085d4e025155 libcruft/misc/quit.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10069
diff changeset
195 }
7481
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
196 }
78f3811155f7 use exceptions in liboctave error handler
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
197 }