Mercurial > octave
comparison libinterp/corefcn/error.cc @ 29961:7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
Files affected: __betainc__.cc, __contourc__.cc, __eigs__.cc,
__expint__.cc, __ftp__.cc, __gammainc__.cc, __ichol__.cc, __ilu__.cc,
__magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, amd.cc, balance.cc,
besselj.cc, bsxfun.cc, call-stack.cc, ccolamd.cc, cellfun.cc, chol.cc,
colamd.cc, colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc,
defaults.cc, dirfns.cc, display.cc, dlmread.cc, dmperm.cc, dot.cc,
eig.cc, ellipj.cc, environment.cc, error.cc, event-manager.cc, fft.cc,
fft2.cc, fftn.cc, file-io.cc, find.cc, gcd.cc, getgrent.cc,
getpwent.cc, getrusage.cc, gsvd.cc, hash.cc, help.cc, hess.cc,
hex2num.cc, input.cc, inv.cc, jsondecode.cc, jsonencode.cc,
load-path.cc, load-save.cc, lookup.cc, lsode.cc, lu.cc, max.cc,
mgorth.cc, oct-hist.cc, ordqz.cc, ordschur.cc, pager.cc, pr-output.cc,
psi.cc, qr.cc, quad.cc, quadcc.cc, qz.cc, rand.cc, regexp.cc,
schur.cc, settings.cc, sighandlers.cc, sparse.cc, spparms.cc,
sqrtm.cc, stream-euler.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc,
symbfact.cc, symtab.cc, syscalls.cc, sysdep.cc, time.cc, toplev.cc,
tril.cc, typecast.cc, urlwrite.cc, utils.cc, variables.cc,
__delaunayn__.cc, __fltk_uigetfile__.cc, __glpk__.cc,
__init_gnuplot__.cc, __ode15__.cc, __voronoi__.cc, audiodevinfo.cc,
audioread.cc, convhulln.cc, fftw.cc, gzip.cc, ov-cell.cc, ov-class.cc,
ov-classdef.cc, ov-fcn-handle.cc, ov-struct.cc, ov-typeinfo.cc,
ov-usr-fcn.cc, octave.cc, lex.ll, oct-parse.yy, profiler.cc,
andpt-eval.cc.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 14 Aug 2021 22:48:52 -0400 |
parents | 939bef0b66e0 |
children | eff73c13fcf3 26f2daafa270 |
comparison
equal
deleted
inserted
replaced
29960:939bef0b66e0 | 29961:7d6709900da7 |
---|---|
1160 error ("rethrow: ERR struct must contain the fields 'message' and 'identifier'"); | 1160 error ("rethrow: ERR struct must contain the fields 'message' and 'identifier'"); |
1161 | 1161 |
1162 std::string msg = err.contents ("message").string_value (); | 1162 std::string msg = err.contents ("message").string_value (); |
1163 std::string id = err.contents ("identifier").string_value (); | 1163 std::string id = err.contents ("identifier").string_value (); |
1164 | 1164 |
1165 octave_map err_stack = octave::init_error_stack (interp); | 1165 octave_map err_stack = init_error_stack (interp); |
1166 | 1166 |
1167 if (err.contains ("stack")) | 1167 if (err.contains ("stack")) |
1168 err_stack = err.contents ("stack").xmap_value ("ERR.STACK must be a struct"); | 1168 err_stack = err.contents ("stack").xmap_value ("ERR.STACK must be a struct"); |
1169 | 1169 |
1170 octave::error_system& es = interp.get_error_system (); | 1170 error_system& es = interp.get_error_system (); |
1171 | 1171 |
1172 es.rethrow_error (id, msg, err_stack); | 1172 es.rethrow_error (id, msg, err_stack); |
1173 | 1173 |
1174 return ovl (); | 1174 return ovl (); |
1175 } | 1175 } |
1270 | 1270 |
1271 octave_value retval; | 1271 octave_value retval; |
1272 | 1272 |
1273 std::string id; | 1273 std::string id; |
1274 std::string message; | 1274 std::string message; |
1275 std::list<octave::frame_info> stack_info; | 1275 std::list<frame_info> stack_info; |
1276 | 1276 |
1277 bool have_fmt = false; | 1277 bool have_fmt = false; |
1278 | 1278 |
1279 if (nargin == 1 && args(0).isstruct ()) | 1279 if (nargin == 1 && args(0).isstruct ()) |
1280 { | 1280 { |
1308 { | 1308 { |
1309 octave_value c = m.getfield ("stack"); | 1309 octave_value c = m.getfield ("stack"); |
1310 | 1310 |
1311 if (c.isstruct ()) | 1311 if (c.isstruct ()) |
1312 stack_info | 1312 stack_info |
1313 = octave::error_system::make_stack_frame_list (c.map_value ()); | 1313 = error_system::make_stack_frame_list (c.map_value ()); |
1314 } | 1314 } |
1315 } | 1315 } |
1316 else | 1316 else |
1317 { | 1317 { |
1318 octave_value_list nargs = args; | 1318 octave_value_list nargs = args; |
1325 { | 1325 { |
1326 octave_value arg; | 1326 octave_value arg; |
1327 | 1327 |
1328 if (have_fmt) | 1328 if (have_fmt) |
1329 { | 1329 { |
1330 octave_value_list tmp = octave::Fsprintf (nargs, 1); | 1330 octave_value_list tmp = Fsprintf (nargs, 1); |
1331 arg = tmp(0); | 1331 arg = tmp(0); |
1332 } | 1332 } |
1333 else | 1333 else |
1334 arg = nargs(0); | 1334 arg = nargs(0); |
1335 | 1335 |
1344 } | 1344 } |
1345 | 1345 |
1346 if (message.empty ()) | 1346 if (message.empty ()) |
1347 return retval; | 1347 return retval; |
1348 | 1348 |
1349 octave::error_system& es = interp.get_error_system (); | 1349 error_system& es = interp.get_error_system (); |
1350 | 1350 |
1351 es.throw_error ("error", id, message, stack_info); | 1351 es.throw_error ("error", id, message, stack_info); |
1352 | 1352 |
1353 return retval; | 1353 return retval; |
1354 } | 1354 } |
1478 octave_value retval; | 1478 octave_value retval; |
1479 | 1479 |
1480 int nargin = args.length (); | 1480 int nargin = args.length (); |
1481 bool done = false; | 1481 bool done = false; |
1482 | 1482 |
1483 octave::error_system& es = interp.get_error_system (); | 1483 error_system& es = interp.get_error_system (); |
1484 | 1484 |
1485 if (nargin > 0 && args.all_strings_p ()) | 1485 if (nargin > 0 && args.all_strings_p ()) |
1486 { | 1486 { |
1487 string_vector argv = args.make_argv ("warning"); | 1487 string_vector argv = args.make_argv ("warning"); |
1488 | 1488 |
1518 octave_scalar_map val = es.warning_query (arg2); | 1518 octave_scalar_map val = es.warning_query (arg2); |
1519 | 1519 |
1520 octave_value curr_state = val.contents ("state"); | 1520 octave_value curr_state = val.contents ("state"); |
1521 | 1521 |
1522 // FIXME: this might be better with a dictionary object. | 1522 // FIXME: this might be better with a dictionary object. |
1523 octave::tree_evaluator& tw = interp.get_evaluator (); | 1523 tree_evaluator& tw = interp.get_evaluator (); |
1524 | 1524 |
1525 octave_value curr_warning_states | 1525 octave_value curr_warning_states |
1526 = tw.get_auto_fcn_var (octave::stack_frame::SAVED_WARNING_STATES); | 1526 = tw.get_auto_fcn_var (stack_frame::SAVED_WARNING_STATES); |
1527 | 1527 |
1528 octave_map m; | 1528 octave_map m; |
1529 | 1529 |
1530 if (curr_warning_states.is_defined ()) | 1530 if (curr_warning_states.is_defined ()) |
1531 m = curr_warning_states.map_value (); | 1531 m = curr_warning_states.map_value (); |
1569 } | 1569 } |
1570 | 1570 |
1571 m.contents ("identifier") = ids; | 1571 m.contents ("identifier") = ids; |
1572 m.contents ("state") = states; | 1572 m.contents ("state") = states; |
1573 | 1573 |
1574 tw.set_auto_fcn_var (octave::stack_frame::SAVED_WARNING_STATES, m); | 1574 tw.set_auto_fcn_var (stack_frame::SAVED_WARNING_STATES, m); |
1575 | 1575 |
1576 // Now ignore the "local" argument, | 1576 // Now ignore the "local" argument, |
1577 // and continue to handle the current setting. | 1577 // and continue to handle the current setting. |
1578 nargin--; | 1578 nargin--; |
1579 } | 1579 } |
1821 octave_value_list args; | 1821 octave_value_list args; |
1822 | 1822 |
1823 args(1) = id; | 1823 args(1) = id; |
1824 args(0) = state; | 1824 args(0) = state; |
1825 | 1825 |
1826 octave::interpreter& interp | 1826 interpreter& interp = __get_interpreter__ ("set_warning_state"); |
1827 = octave::__get_interpreter__ ("set_warning_state"); | 1827 |
1828 | 1828 return Fwarning (interp, args, 1); |
1829 return octave::Fwarning (interp, args, 1); | |
1830 } | 1829 } |
1831 | 1830 |
1832 octave_value_list | 1831 octave_value_list |
1833 set_warning_state (const octave_value_list& args) | 1832 set_warning_state (const octave_value_list& args) |
1834 { | 1833 { |
1835 octave::interpreter& interp | 1834 interpreter& interp = __get_interpreter__ ("set_warning_state"); |
1836 = octave::__get_interpreter__ ("set_warning_state"); | 1835 |
1837 | 1836 return Fwarning (interp, args, 1); |
1838 return octave::Fwarning (interp, args, 1); | |
1839 } | 1837 } |
1840 | 1838 |
1841 int | 1839 int |
1842 warning_enabled (const std::string& id) | 1840 warning_enabled (const std::string& id) |
1843 { | 1841 { |
1844 octave::error_system& es = octave::__get_error_system__ ("warning_enabled"); | 1842 error_system& es = __get_error_system__ ("warning_enabled"); |
1845 | 1843 |
1846 return es.warning_enabled (id); | 1844 return es.warning_enabled (id); |
1847 } | 1845 } |
1848 | 1846 |
1849 void | 1847 void |
1850 disable_warning (const std::string& id) | 1848 disable_warning (const std::string& id) |
1851 { | 1849 { |
1852 octave::error_system& es = octave::__get_error_system__ ("disable_warning"); | 1850 error_system& es = __get_error_system__ ("disable_warning"); |
1853 | 1851 |
1854 es.disable_warning (id); | 1852 es.disable_warning (id); |
1855 } | 1853 } |
1856 | 1854 |
1857 DEFMETHOD (lasterror, interp, args, , | 1855 DEFMETHOD (lasterror, interp, args, , |
1904 int nargin = args.length (); | 1902 int nargin = args.length (); |
1905 | 1903 |
1906 if (nargin > 1) | 1904 if (nargin > 1) |
1907 print_usage (); | 1905 print_usage (); |
1908 | 1906 |
1909 octave::error_system& es = interp.get_error_system (); | 1907 error_system& es = interp.get_error_system (); |
1910 | 1908 |
1911 octave_scalar_map err; | 1909 octave_scalar_map err; |
1912 | 1910 |
1913 err.assign ("message", es.last_error_message ()); | 1911 err.assign ("message", es.last_error_message ()); |
1914 err.assign ("identifier", es.last_error_id ()); | 1912 err.assign ("identifier", es.last_error_id ()); |
1915 | 1913 |
1916 err.assign ("stack", octave_value (es.last_error_stack ())); | 1914 err.assign ("stack", octave_value (es.last_error_stack ())); |
1917 | 1915 |
1918 if (nargin == 1) | 1916 if (nargin == 1) |
1919 { | 1917 { |
1920 octave::tree_evaluator& tw = interp.get_evaluator (); | 1918 tree_evaluator& tw = interp.get_evaluator (); |
1921 | 1919 |
1922 if (args(0).is_string ()) | 1920 if (args(0).is_string ()) |
1923 { | 1921 { |
1924 if (args(0).string_value () != "reset") | 1922 if (args(0).string_value () != "reset") |
1925 error ("lasterror: unrecognized string argument"); | 1923 error ("lasterror: unrecognized string argument"); |
2050 int nargin = args.length (); | 2048 int nargin = args.length (); |
2051 | 2049 |
2052 if (nargin > 2) | 2050 if (nargin > 2) |
2053 print_usage (); | 2051 print_usage (); |
2054 | 2052 |
2055 octave::error_system& es = interp.get_error_system (); | 2053 error_system& es = interp.get_error_system (); |
2056 | 2054 |
2057 string_vector argv = args.make_argv ("lasterr"); | 2055 string_vector argv = args.make_argv ("lasterr"); |
2058 | 2056 |
2059 std::string prev_error_id = es.last_error_id (); | 2057 std::string prev_error_id = es.last_error_id (); |
2060 std::string prev_error_message = es.last_error_message (); | 2058 std::string prev_error_message = es.last_error_message (); |
2095 int nargin = args.length (); | 2093 int nargin = args.length (); |
2096 | 2094 |
2097 if (nargin > 2) | 2095 if (nargin > 2) |
2098 print_usage (); | 2096 print_usage (); |
2099 | 2097 |
2100 octave::error_system& es = interp.get_error_system (); | 2098 error_system& es = interp.get_error_system (); |
2101 | 2099 |
2102 string_vector argv = args.make_argv ("lastwarn"); | 2100 string_vector argv = args.make_argv ("lastwarn"); |
2103 | 2101 |
2104 std::string prev_warning_id = es.last_warning_id (); | 2102 std::string prev_warning_id = es.last_warning_id (); |
2105 std::string prev_warning_message = es.last_warning_message (); | 2103 std::string prev_warning_message = es.last_warning_message (); |
2132 When called from inside a function with the @qcode{"local"} option, the | 2130 When called from inside a function with the @qcode{"local"} option, the |
2133 variable is changed locally for the function and any subroutines it calls. | 2131 variable is changed locally for the function and any subroutines it calls. |
2134 The original variable value is restored when exiting the function. | 2132 The original variable value is restored when exiting the function. |
2135 @end deftypefn */) | 2133 @end deftypefn */) |
2136 { | 2134 { |
2137 octave::error_system& es = interp.get_error_system (); | 2135 error_system& es = interp.get_error_system (); |
2138 | 2136 |
2139 return es.beep_on_error (args, nargout); | 2137 return es.beep_on_error (args, nargout); |
2140 } | 2138 } |
2141 | 2139 |
2142 DEFMETHOD (debug_on_error, interp, args, nargout, | 2140 DEFMETHOD (debug_on_error, interp, args, nargout, |
2154 variable is changed locally for the function and any subroutines it calls. | 2152 variable is changed locally for the function and any subroutines it calls. |
2155 The original variable value is restored when exiting the function. | 2153 The original variable value is restored when exiting the function. |
2156 @seealso{debug_on_warning, debug_on_interrupt} | 2154 @seealso{debug_on_warning, debug_on_interrupt} |
2157 @end deftypefn */) | 2155 @end deftypefn */) |
2158 { | 2156 { |
2159 octave::error_system& es = interp.get_error_system (); | 2157 error_system& es = interp.get_error_system (); |
2160 | 2158 |
2161 return es.debug_on_error (args, nargout); | 2159 return es.debug_on_error (args, nargout); |
2162 } | 2160 } |
2163 | 2161 |
2164 DEFMETHOD (debug_on_warning, interp, args, nargout, | 2162 DEFMETHOD (debug_on_warning, interp, args, nargout, |
2173 variable is changed locally for the function and any subroutines it calls. | 2171 variable is changed locally for the function and any subroutines it calls. |
2174 The original variable value is restored when exiting the function. | 2172 The original variable value is restored when exiting the function. |
2175 @seealso{debug_on_error, debug_on_interrupt} | 2173 @seealso{debug_on_error, debug_on_interrupt} |
2176 @end deftypefn */) | 2174 @end deftypefn */) |
2177 { | 2175 { |
2178 octave::error_system& es = interp.get_error_system (); | 2176 error_system& es = interp.get_error_system (); |
2179 | 2177 |
2180 return es.debug_on_warning (args, nargout); | 2178 return es.debug_on_warning (args, nargout); |
2181 } | 2179 } |
2182 | 2180 |
2183 void | 2181 void |
2184 interpreter_try (octave::unwind_protect& frame) | 2182 interpreter_try (unwind_protect& frame) |
2185 { | 2183 { |
2186 octave::error_system& es | 2184 error_system& es = __get_error_system__ ("interpreter_try"); |
2187 = octave::__get_error_system__ ("interpreter_try"); | |
2188 | 2185 |
2189 es.interpreter_try (frame); | 2186 es.interpreter_try (frame); |
2190 } | 2187 } |
2191 | 2188 |
2192 OCTAVE_NAMESPACE_END | 2189 OCTAVE_NAMESPACE_END |