Mercurial > octave
annotate libinterp/corefcn/error.cc @ 31605:e88a07dec498 stable
maint: Use macros to begin/end C++ namespaces.
* oct-conf-post-public.in.h: Define two macros (OCTAVE_BEGIN_NAMESPACE,
OCTAVE_END_NAMESPACE) that can be used to start/end a namespace.
* mk-opts.pl, build-env.h, build-env.in.cc, __betainc__.cc, __contourc__.cc,
__dsearchn__.cc, __eigs__.cc, __expint__.cc, __ftp__.cc, __gammainc__.cc,
__ichol__.cc, __ilu__.cc, __isprimelarge__.cc, __lin_interpn__.cc,
__magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, amd.cc, auto-shlib.cc,
auto-shlib.h, balance.cc, base-text-renderer.cc, base-text-renderer.h,
besselj.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.cc, c-file-ptr-stream.h,
call-stack.cc, call-stack.h, ccolamd.cc, cellfun.cc, chol.cc, colamd.cc,
colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, data.h, debug.cc,
defaults.cc, defaults.h, defun-int.h, defun.cc, det.cc, dirfns.cc, display.cc,
display.h, dlmread.cc, dmperm.cc, dot.cc, dynamic-ld.cc, dynamic-ld.h, eig.cc,
ellipj.cc, environment.cc, environment.h, error.cc, error.h, errwarn.h,
event-manager.cc, event-manager.h, event-queue.cc, event-queue.h, fcn-info.cc,
fcn-info.h, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc,
ft-text-renderer.cc, ft-text-renderer.h, gcd.cc, getgrent.cc, getpwent.cc,
getrusage.cc, givens.cc, gl-render.cc, gl-render.h, gl2ps-print.cc,
gl2ps-print.h, graphics-toolkit.cc, graphics-toolkit.h, graphics.cc,
graphics.in.h, gsvd.cc, gtk-manager.cc, gtk-manager.h, hash.cc, help.cc,
help.h, hess.cc, hex2num.cc, hook-fcn.cc, hook-fcn.h, input.cc, input.h,
interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h,
inv.cc, jsondecode.cc, jsonencode.cc, kron.cc, latex-text-renderer.cc,
latex-text-renderer.h, load-path.cc, load-path.h, load-save.cc, load-save.h,
lookup.cc, ls-ascii-helper.cc, ls-ascii-helper.h, ls-oct-text.cc, ls-utils.cc,
ls-utils.h, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex-private.h,
mex.cc, mgorth.cc, nproc.cc, oct-fstrm.cc, oct-fstrm.h, oct-hdf5-types.cc,
oct-hdf5-types.h, oct-hist.cc, oct-hist.h, oct-iostrm.cc, oct-iostrm.h,
oct-opengl.h, oct-prcstrm.cc, oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h,
oct-process.cc, oct-process.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h,
oct-strstrm.cc, oct-strstrm.h, oct-tex-lexer.in.ll, oct-tex-parser.yy,
ordqz.cc, ordschur.cc, pager.cc, pager.h, pinv.cc, pow2.cc, pr-flt-fmt.cc,
pr-output.cc, procstream.cc, procstream.h, psi.cc, qr.cc, quad.cc, quadcc.cc,
qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, settings.cc, settings.h,
sighandlers.cc, sighandlers.h, sparse-xdiv.cc, sparse-xdiv.h, sparse-xpow.cc,
sparse-xpow.h, sparse.cc, spparms.cc, sqrtm.cc, stack-frame.cc, stack-frame.h,
stream-euler.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc,
symbfact.cc, syminfo.cc, syminfo.h, symrcm.cc, symrec.cc, symrec.h,
symscope.cc, symscope.h, symtab.cc, symtab.h, syscalls.cc, sysdep.cc, sysdep.h,
text-engine.cc, text-engine.h, text-renderer.cc, text-renderer.h, time.cc,
toplev.cc, tril.cc, tsearch.cc, typecast.cc, url-handle-manager.cc,
url-handle-manager.h, urlwrite.cc, utils.cc, utils.h, variables.cc,
variables.h, xdiv.cc, xdiv.h, xnorm.cc, xnorm.h, xpow.cc, xpow.h,
__delaunayn__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc,
__init_gnuplot__.cc, __ode15__.cc, __voronoi__.cc, audiodevinfo.cc,
audioread.cc, convhulln.cc, fftw.cc, gzip.cc, mk-build-env-features.sh,
mk-builtins.pl, cdef-class.cc, cdef-class.h, cdef-fwd.h, cdef-manager.cc,
cdef-manager.h, cdef-method.cc, cdef-method.h, cdef-object.cc, cdef-object.h,
cdef-package.cc, cdef-package.h, cdef-property.cc, cdef-property.h,
cdef-utils.cc, cdef-utils.h, ov-base.cc, ov-base.h, ov-bool-mat.cc,
ov-builtin.h, ov-cell.cc, ov-class.cc, ov-class.h, ov-classdef.cc,
ov-classdef.h, ov-complex.cc, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn.h,
ov-java.cc, ov-java.h, ov-mex-fcn.h, ov-null-mat.cc, ov-oncleanup.cc,
ov-struct.cc, ov-typeinfo.cc, ov-typeinfo.h, ov-usr-fcn.cc, ov-usr-fcn.h,
ov.cc, ov.h, octave.cc, octave.h, mk-ops.sh, op-b-b.cc, op-b-bm.cc,
op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc,
op-chm.cc, op-class.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc,
op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc,
op-cs-scm.cc, op-cs-sm.cc, op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc,
op-dm-template.cc, op-dms-template.cc, op-fcdm-fcdm.cc, op-fcm-fcm.cc,
op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcn.cc, op-fcs-fcm.cc,
op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fdm.cc, op-fm-fcm.cc,
op-fm-fcs.cc, op-fm-fm.cc, op-fm-fs.cc, op-fs-fcm.cc, op-fs-fcs.cc,
op-fs-fm.cc, op-fs-fs.cc, op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc,
op-i8-i8.cc, op-int-concat.cc, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc,
op-m-scm.cc, op-m-sm.cc, op-mi.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc,
op-pm-template.cc, op-range.cc, op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc,
op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc,
op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc,
op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc,
op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc,
op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc, ops.h,
anon-fcn-validator.cc, anon-fcn-validator.h, bp-table.cc, bp-table.h,
comment-list.cc, comment-list.h, filepos.h, lex.h, lex.ll, oct-lvalue.cc,
oct-lvalue.h, oct-parse.yy, parse.h, profiler.cc, profiler.h,
pt-anon-scopes.cc, pt-anon-scopes.h, pt-arg-list.cc, pt-arg-list.h,
pt-args-block.cc, pt-args-block.h, pt-array-list.cc, pt-array-list.h,
pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h,
pt-cbinop.cc, pt-cbinop.h, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h,
pt-classdef.cc, pt-classdef.h, pt-cmd.h, pt-colon.cc, pt-colon.h, pt-const.cc,
pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc,
pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-id.cc,
pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.cc,
pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc,
pt-select.h, pt-spmd.cc, pt-spmd.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc,
pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-vm-eval.cc, pt-walk.cc, pt-walk.h,
pt.cc, pt.h, token.cc, token.h, Range.cc, Range.h, idx-vector.cc, idx-vector.h,
range-fwd.h, CollocWt.cc, CollocWt.h, aepbalance.cc, aepbalance.h, chol.cc,
chol.h, gepbalance.cc, gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h,
lo-mappers.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h,
oct-convn.cc, oct-convn.h, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-norm.h,
oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc,
qrp.h, randgamma.cc, randgamma.h, randmtzig.cc, randmtzig.h, randpoisson.cc,
randpoisson.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h, sparse-lu.cc,
sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, child-list.cc,
child-list.h, dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc,
file-stat.h, lo-sysdep.cc, lo-sysdep.h, lo-sysinfo.cc, lo-sysinfo.h,
mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h,
oct-password.cc, oct-password.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc,
oct-time.h, oct-uname.cc, oct-uname.h, action-container.cc, action-container.h,
base-list.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, f77-fcn.h,
file-info.cc, file-info.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-hash.cc,
lo-hash.h, lo-ieee.h, lo-regexp.cc, lo-regexp.h, lo-utils.cc, lo-utils.h,
oct-base64.cc, oct-base64.h, oct-glob.cc, oct-glob.h, oct-inttypes.h,
oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-shlib.cc, oct-shlib.h,
oct-sparse.cc, oct-sparse.h, oct-string.h, octave-preserve-stream-state.h,
pathsearch.cc, pathsearch.h, quit.cc, quit.h, unwind-prot.cc, unwind-prot.h,
url-transfer.cc, url-transfer.h : Use new macros to begin/end C++ namespaces.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 01 Dec 2022 14:23:45 -0800 |
parents | 785ac0d19116 |
children | dfa5d9c3ae72 aac27ad79be6 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30377
diff
changeset
|
3 // Copyright (C) 1993-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
1 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21698
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
27 # include "config.h" |
1 | 28 #endif |
29 | |
1343 | 30 #include <cstdarg> |
23448
e1c02e7126a9
avoid calling abort if possible; include cstdlib for declaration if needed
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
31 #include <cstdlib> |
1633 | 32 #include <cstring> |
1343 | 33 |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
34 #include <algorithm> |
19439
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
19421
diff
changeset
|
35 #include <iomanip> |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
36 #include <iostream> |
5765 | 37 #include <sstream> |
1728 | 38 #include <string> |
39 | |
27471 | 40 #include "quit.h" |
41 | |
23137
334119c390b3
move bp_table class to separate file
John W. Eaton <jwe@octave.org>
parents:
23127
diff
changeset
|
42 #include "bp-table.h" |
23454
30b6eccd6708
use builtin-defun-decls.h to ensure declarations of interpreter functions
John W. Eaton <jwe@octave.org>
parents:
23450
diff
changeset
|
43 #include "builtin-defun-decls.h" |
1352 | 44 #include "defun.h" |
1 | 45 #include "error.h" |
29502
76fdbe78884f
allow event manager to handle display of execution exceptions
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
46 #include "event-manager.h" |
3707 | 47 #include "input.h" |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23465
diff
changeset
|
48 #include "interpreter-private.h" |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23465
diff
changeset
|
49 #include "interpreter.h" |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23465
diff
changeset
|
50 #include "oct-map.h" |
22089
c2c668b3051b
use classes for octave application and interpreter
John W. Eaton <jwe@octave.org>
parents:
21990
diff
changeset
|
51 #include "octave.h" |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23465
diff
changeset
|
52 #include "ov-usr-fcn.h" |
2370 | 53 #include "ov.h" |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23465
diff
changeset
|
54 #include "ovl.h" |
1742 | 55 #include "pager.h" |
18742
bd334b6af257
Enter true debug mode after debug_on_(warning|error) (bug #37574).
Rik <rik@octave.org>
parents:
18222
diff
changeset
|
56 #include "pt-eval.h" |
3707 | 57 #include "unwind-prot.h" |
1352 | 58 #include "utils.h" |
2370 | 59 #include "variables.h" |
1 | 60 |
27471 | 61 static std::string |
62 format_message (const char *fmt, va_list args) | |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
63 { |
27471 | 64 if (! fmt) |
65 return ""; | |
27199
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27161
diff
changeset
|
66 |
27471 | 67 std::ostringstream output_buf; |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
68 |
27471 | 69 octave::vformat (output_buf, fmt, args); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
70 |
27471 | 71 return output_buf.str (); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
72 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
73 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
74 OCTAVE_NORETURN |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
75 static void |
29171
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29117
diff
changeset
|
76 error_1 (octave::execution_exception& ee, const char *id, const char *fmt, |
27471 | 77 va_list args) |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
78 { |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30896
diff
changeset
|
79 octave::error_system& es = octave::__get_error_system__ (); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
80 |
29171
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29117
diff
changeset
|
81 es.error_1 (ee, id, fmt, args); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
82 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
83 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
84 OCTAVE_NORETURN |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
85 static void |
27471 | 86 error_1 (const char *id, const char *fmt, va_list args) |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
87 { |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30896
diff
changeset
|
88 octave::error_system& es = octave::__get_error_system__ (); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
89 |
27471 | 90 es.error_1 (id, fmt, args); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
91 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
92 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
93 static int |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
94 check_state (const std::string& state) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
95 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
96 // -1: not found |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
97 // 0: found, "off" |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
98 // 1: found, "on" |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
99 // 2: found, "error" |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
100 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
101 if (state == "off") |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
102 return 0; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
103 else if (state == "on") |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
104 return 1; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
105 else if (state == "error") |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
106 return 2; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
107 else |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
108 return -1; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
109 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
110 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
111 static void |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
112 vwarning (const char *id, const char *fmt, va_list args) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
113 { |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30896
diff
changeset
|
114 octave::error_system& es = octave::__get_error_system__ (); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
115 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
116 es.vwarning (id, fmt, args); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
117 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
118 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
119 static void |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
120 defun_usage_message (const char *fmt, ...) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
121 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
122 va_list args; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
123 va_start (args, fmt); |
27471 | 124 error_1 ("", fmt, args); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
125 va_end (args); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
126 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
127 |
30896
c9788d7f6e65
maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents:
30888
diff
changeset
|
128 typedef void (*error_fcn)(const char *, const char *, ...); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
129 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
130 static std::string |
30896
c9788d7f6e65
maint: Use "fcn" as preferred abbreviation for "function" in libinterp/.
Rik <rik@octave.org>
parents:
30888
diff
changeset
|
131 handle_message (error_fcn f, const char *id, const char *msg, |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
132 const octave_value_list& args, bool have_fmt) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
133 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
134 std::string retval; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
135 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
136 std::string tmpstr; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
137 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
138 if (args.length () > 0) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
139 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
140 octave_value arg; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
141 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
142 if (have_fmt) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
143 { |
29958
32c3a5805893
move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29956
diff
changeset
|
144 octave_value_list tmp = octave::Fsprintf (args, 1); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
145 arg = tmp(0); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
146 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
147 else |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
148 arg = args(0); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
149 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
150 if (arg.is_defined ()) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
151 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
152 if (arg.isempty ()) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
153 return retval; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
154 else if (arg.is_string ()) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
155 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
156 tmpstr = arg.string_value (); // 2-stage assignment required |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
157 msg = tmpstr.c_str (); // in order to generate pointer |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
158 // to valid memory. |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
159 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
160 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
161 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
162 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
163 // Ugh. |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
164 |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
165 std::size_t len = strlen (msg); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
166 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
167 if (len > 0) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
168 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
169 if (msg[len - 1] == '\n') |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
170 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
171 if (len > 1) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
172 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
173 std::string tmp_msg (msg, len - 1); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
174 f (id, "%s\n", tmp_msg.c_str ()); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
175 retval = tmp_msg; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
176 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
177 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
178 else |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
179 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
180 f (id, "%s", msg); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
181 retval = msg; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
182 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
183 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
184 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
185 return retval; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
186 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
187 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
188 // Determine whether the first argument to error or warning function |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
189 // should be handled as the message identifier or as the format string. |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
190 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
191 static bool |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
192 maybe_extract_message_id (const std::string& caller, |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
193 const octave_value_list& args, |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
194 octave_value_list& nargs, |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
195 std::string& id) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
196 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
197 nargs = args; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
198 id = ""; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
199 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
200 int nargin = args.length (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
201 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
202 bool have_fmt = nargin > 1; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
203 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
204 if (nargin > 0) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
205 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
206 std::string arg1 = args(0).string_value (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
207 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
208 // For compatibility with Matlab, an identifier must contain ':', |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
209 // but not at the beginning or the end, and it must not contain '%' |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
210 // (even if it is not a valid conversion operator) or whitespace. |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
211 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
212 if (arg1.find_first_of ("% \f\n\r\t\v") == std::string::npos |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
213 && arg1.find (':') != std::string::npos |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
214 && arg1[0] != ':' |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
215 && arg1.back () != ':') |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
216 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
217 if (nargin > 1) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
218 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
219 id = arg1; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
220 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
221 nargs.resize (nargin-1); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
222 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
223 for (int i = 1; i < nargin; i++) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
224 nargs(i-1) = args(i); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
225 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
226 else |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
227 nargs(0) = "call to " + caller |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
228 + " with message identifier '" + arg1 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
229 + "' requires message"; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
230 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
231 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
232 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
233 return have_fmt; |
4318 | 234 } |
235 | |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31577
diff
changeset
|
236 OCTAVE_BEGIN_NAMESPACE(octave) |
29960
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
237 |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
238 static octave_scalar_map |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
239 init_warning_options (const std::string& state) |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
240 { |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
241 octave_scalar_map initw; |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
242 |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
243 initw.setfield ("identifier", "all"); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
244 initw.setfield ("state", state); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
245 |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
246 return initw; |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
247 } |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
248 |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
249 static octave_map |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
250 init_error_stack (interpreter& interp) |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
251 { |
27199
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27161
diff
changeset
|
252 tree_evaluator& tw = interp.get_evaluator (); |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27161
diff
changeset
|
253 |
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27161
diff
changeset
|
254 return tw.empty_backtrace (); |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
255 } |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
256 |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
257 error_system::error_system (interpreter& interp) |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
258 : m_interpreter (interp), |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
259 m_debug_on_error (false), |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
260 m_debug_on_caught (false), |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
261 m_debug_on_warning (false), |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
262 m_discard_warning_messages (false), |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
263 m_beep_on_error (false), |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
264 m_backtrace_on_warning (true), |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
265 m_verbose_warning (false), |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
266 m_quiet_warning (false), |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
267 m_warning_options (init_warning_options ("on")), |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
268 m_last_error_message (), |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
269 m_last_warning_message (), |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
270 m_last_warning_id (), |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
271 m_last_error_id (), |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
272 m_last_error_stack (init_error_stack (interp)) |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
273 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
274 initialize_default_warning_state (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
275 } |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
276 |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
277 octave_value |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
278 error_system::debug_on_error (const octave_value_list& args, int nargout) |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
279 { |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
280 return set_internal_variable (m_debug_on_error, args, nargout, |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
281 "debug_on_error"); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
282 } |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
283 |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
284 octave_value |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
285 error_system::debug_on_caught (const octave_value_list& args, int nargout) |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
286 { |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
287 return set_internal_variable (m_debug_on_caught, args, nargout, |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
288 "debug_on_caught"); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
289 } |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
290 |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
291 octave_value |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
292 error_system::debug_on_warning (const octave_value_list& args, int nargout) |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
293 { |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
294 return set_internal_variable (m_debug_on_warning, args, nargout, |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
295 "debug_on_warning"); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
296 } |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
297 |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
298 octave_value |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
299 error_system::discard_warning_messages (const octave_value_list& args, |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
300 int nargout) |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
301 { |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
302 return set_internal_variable (m_discard_warning_messages, args, nargout, |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
303 "discard_warning_messages"); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
304 } |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
305 |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
306 octave_value |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
307 error_system::beep_on_error (const octave_value_list& args, int nargout) |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
308 { |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
309 return set_internal_variable (m_beep_on_error, args, nargout, |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
310 "beep_on_error"); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
311 } |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
312 |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
313 octave_value |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
314 error_system::backtrace_on_warning (const octave_value_list& args, |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
315 int nargout) |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
316 { |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
317 return set_internal_variable (m_backtrace_on_warning, args, nargout, |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
318 "backtrace_on_warning"); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
319 } |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
320 |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
321 octave_value |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
322 error_system::verbose_warning (const octave_value_list& args, int nargout) |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
323 { |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
324 return set_internal_variable (m_verbose_warning, args, nargout, |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
325 "verbose_warning"); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
326 } |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
327 |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
328 octave_value |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
329 error_system::quiet_warning (const octave_value_list& args, int nargout) |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
330 { |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
331 return set_internal_variable (m_quiet_warning, args, nargout, |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
332 "quiet_warning"); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
333 } |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
334 |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
335 octave_value |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
336 error_system::last_error_message (const octave_value_list& args, int nargout) |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
337 { |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
338 return set_internal_variable (m_last_error_message, args, nargout, |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
339 "last_error_message"); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
340 } |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
341 |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
342 octave_value |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
343 error_system::last_warning_message (const octave_value_list& args, |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
344 int nargout) |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
345 { |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
346 return set_internal_variable (m_last_warning_message, args, nargout, |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
347 "last_warning_message"); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
348 } |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
349 |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
350 octave_value |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
351 error_system::last_warning_id (const octave_value_list& args, int nargout) |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
352 { |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
353 return set_internal_variable (m_last_warning_id, args, nargout, |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
354 "last_warning_id"); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
355 } |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
356 |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
357 octave_value |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
358 error_system::last_error_id (const octave_value_list& args, int nargout) |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
359 { |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
360 return set_internal_variable (m_last_error_id, args, nargout, |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
361 "last_error_id"); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
362 } |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
363 |
27472
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
364 // Use static fields for the best efficiency. |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
365 // NOTE: C++0x will allow these two to be merged into one. |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
366 static const char *bt_fieldnames[] = |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
367 { "file", "name", "line", "column", nullptr }; |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
368 |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
369 static const octave_fields bt_fields (bt_fieldnames); |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
370 |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
371 octave_map |
28857
43ad651cf5a0
eliminate unnecessary uses of octave:: namespace qualifier
John W. Eaton <jwe@octave.org>
parents:
28823
diff
changeset
|
372 error_system::make_stack_map (const std::list<frame_info>& frames) |
27472
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
373 { |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
374 std::size_t nframes = frames.size (); |
27472
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
375 |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
376 octave_map retval (dim_vector (nframes, 1), bt_fields); |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
377 |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
378 Cell& file = retval.contents (0); |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
379 Cell& name = retval.contents (1); |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
380 Cell& line = retval.contents (2); |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
381 Cell& column = retval.contents (3); |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
382 |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
383 octave_idx_type k = 0; |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
384 |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
385 for (const auto& frm : frames) |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
386 { |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
387 file(k) = frm.file_name (); |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
388 name(k) = frm.fcn_name (); |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
389 line(k) = frm.line (); |
30666
8c6486ffc1d9
Fix error in rethrow with anonymous functions (bug #61841).
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
390 column(k) = frm.column (); |
27472
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
391 |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
392 k++; |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
393 } |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
394 |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
395 return retval; |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
396 } |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
397 |
28857
43ad651cf5a0
eliminate unnecessary uses of octave:: namespace qualifier
John W. Eaton <jwe@octave.org>
parents:
28823
diff
changeset
|
398 std::list<frame_info> |
27472
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
399 error_system::make_stack_frame_list (const octave_map& stack) |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
400 { |
28857
43ad651cf5a0
eliminate unnecessary uses of octave:: namespace qualifier
John W. Eaton <jwe@octave.org>
parents:
28823
diff
changeset
|
401 std::list<frame_info> frames; |
27472
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
402 |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
403 Cell file = stack.contents ("file"); |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
404 Cell name = stack.contents ("name"); |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
405 Cell line = stack.contents ("line"); |
30666
8c6486ffc1d9
Fix error in rethrow with anonymous functions (bug #61841).
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
406 Cell column = stack.contents ("column"); |
27472
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
407 |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
408 octave_idx_type nel = name.numel (); |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
409 |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
410 for (octave_idx_type i = 0; i < nel; i++) |
28857
43ad651cf5a0
eliminate unnecessary uses of octave:: namespace qualifier
John W. Eaton <jwe@octave.org>
parents:
28823
diff
changeset
|
411 frames.push_back (frame_info (file(i).string_value (), |
43ad651cf5a0
eliminate unnecessary uses of octave:: namespace qualifier
John W. Eaton <jwe@octave.org>
parents:
28823
diff
changeset
|
412 name(i).string_value (), |
43ad651cf5a0
eliminate unnecessary uses of octave:: namespace qualifier
John W. Eaton <jwe@octave.org>
parents:
28823
diff
changeset
|
413 line(i).int_value (), |
30666
8c6486ffc1d9
Fix error in rethrow with anonymous functions (bug #61841).
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
414 column(i).int_value ())); |
27472
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
415 |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
416 return frames; |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
417 } |
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
418 |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
419 // For given warning ID, return 0 if warnings are disabled, 1 if |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
420 // enabled, and 2 if the given ID should be an error instead of a |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
421 // warning. |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
422 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
423 int error_system::warning_enabled (const std::string& id) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
424 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
425 int retval = 0; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
426 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
427 int all_state = -1; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
428 int id_state = -1; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
429 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
430 octave_map opts = warning_options (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
431 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
432 octave_idx_type nel = opts.numel (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
433 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
434 if (nel > 0) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
435 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
436 Cell identifier = opts.contents ("identifier"); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
437 Cell state = opts.contents ("state"); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
438 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
439 bool all_found = false; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
440 bool id_found = false; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
441 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
442 for (octave_idx_type i = 0; i < nel; i++) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
443 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
444 octave_value ov = identifier(i); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
445 std::string ovs = ov.string_value (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
446 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
447 if (! all_found && ovs == "all") |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
448 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
449 all_state = check_state (state(i).string_value ()); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
450 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
451 if (all_state >= 0) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
452 all_found = true; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
453 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
454 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
455 if (! id_found && ovs == id) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
456 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
457 id_state = check_state (state(i).string_value ()); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
458 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
459 if (id_state >= 0) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
460 id_found = true; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
461 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
462 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
463 if (all_found && id_found) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
464 break; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
465 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
466 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
467 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
468 // If "all" is not present, assume warnings are enabled. |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
469 if (all_state == -1) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
470 all_state = 1; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
471 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
472 if (all_state == 0) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
473 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
474 if (id_state >= 0) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
475 retval = id_state; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
476 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
477 else if (all_state == 1) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
478 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
479 if (id_state == 0 || id_state == 2) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
480 retval = id_state; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
481 else |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
482 retval = all_state; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
483 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
484 else if (all_state == 2) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
485 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
486 if (id_state == 0) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
487 retval= id_state; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
488 else |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
489 retval = all_state; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
490 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
491 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
492 return retval; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
493 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
494 |
27471 | 495 void error_system::vusage (const char *id, const char *fmt, va_list args) |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
496 { |
27471 | 497 std::string str_id = id ? id : ""; |
498 std::string message = format_message (fmt, args); | |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
499 |
31577
785ac0d19116
error.cc: Fix potential null pointer dereference (bug #63436)
Arun Giridhar <arungiridhar@gmail.com>
parents:
31105
diff
changeset
|
500 throw_error ("usage", str_id, message); |
27471 | 501 } |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
502 |
27471 | 503 void error_system::vwarning (const char *name, const char *id, |
504 const char *fmt, va_list args) | |
505 { | |
506 flush_stdout (); | |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
507 |
27471 | 508 std::string base_msg = format_message (fmt, args); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
509 std::string msg_string; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
510 |
27471 | 511 if (name) |
512 msg_string = std::string (name) + ": "; | |
513 | |
514 msg_string += base_msg; | |
515 | |
516 bool fmt_suppresses_backtrace = false; | |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
517 std::size_t fmt_len = (fmt ? strlen (fmt) : 0); |
27471 | 518 fmt_suppresses_backtrace = (fmt_len > 0 && fmt[fmt_len-1] == '\n'); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
519 |
27471 | 520 if (! fmt_suppresses_backtrace) |
521 msg_string += '\n'; | |
522 | |
523 last_warning_id (id); | |
524 last_warning_message (base_msg); | |
525 | |
526 if (discard_warning_messages ()) | |
527 return; | |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
528 |
27199
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27161
diff
changeset
|
529 tree_evaluator& tw = m_interpreter.get_evaluator (); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
530 |
27471 | 531 bool in_user_code = tw.in_user_code (); |
532 | |
533 if (! quiet_warning ()) | |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
534 { |
27471 | 535 octave_diary << msg_string; |
536 std::cerr << msg_string; | |
27199
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27161
diff
changeset
|
537 |
27471 | 538 if (! fmt_suppresses_backtrace && in_user_code |
539 && backtrace_on_warning () | |
540 && ! discard_warning_messages ()) | |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
541 { |
27471 | 542 std::string bt_msg = tw.backtrace_message (); |
543 | |
544 if (! bt_msg.empty ()) | |
545 bt_msg = "warning: called from\n" + bt_msg; | |
546 | |
547 octave_diary << bt_msg << std::endl; | |
548 std::cerr << bt_msg << std::endl; | |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
549 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
550 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
551 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
552 bp_table& bptab = tw.get_bp_table (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
553 |
27471 | 554 if ((m_interpreter.interactive () |
555 || application::forced_interactive ()) | |
556 && debug_on_warning () && in_user_code && bptab.debug_on_warn (id)) | |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
557 { |
28823
26cfccfee9a0
Replace unwind_protect with more efficient constructs (bug #59192).
Rik <rik@octave.org>
parents:
28752
diff
changeset
|
558 unwind_protect_var<bool> restore_var (m_debug_on_warning, false); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
559 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
560 tw.enter_debugger (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
561 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
562 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
563 |
29171
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29117
diff
changeset
|
564 void error_system::error_1 (execution_exception& ee, const char *id, |
27471 | 565 const char *fmt, va_list args) |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
566 { |
29171
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29117
diff
changeset
|
567 ee.set_identifier (id); |
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29117
diff
changeset
|
568 ee.set_message (format_message (fmt, args)); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
569 |
29171
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29117
diff
changeset
|
570 throw_error (ee); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
571 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
572 |
27471 | 573 void error_system::error_1 (const char *id, const char *fmt, |
574 va_list args) | |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
575 { |
27471 | 576 std::string message = format_message (fmt, args); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
577 |
27471 | 578 std::list<frame_info> stack_info; |
27199
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27161
diff
changeset
|
579 |
27471 | 580 throw_error ("error", id, message); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
581 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
582 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
583 void error_system::vwarning (const char *id, const char *fmt, va_list args) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
584 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
585 int warn_opt = warning_enabled (id); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
586 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
587 if (warn_opt == 2) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
588 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
589 // Handle this warning as an error. |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
590 |
27471 | 591 error_1 (id, fmt, args); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
592 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
593 else if (warn_opt == 1) |
27471 | 594 vwarning ("warning", id, fmt, args); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
595 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
596 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
597 void error_system::rethrow_error (const std::string& id, |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
598 const std::string& msg, |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
599 const octave_map& stack) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
600 { |
27471 | 601 std::list<frame_info> stack_info; |
602 | |
29171
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29117
diff
changeset
|
603 execution_exception ee ("error", id, msg, stack_info); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
604 |
30666
8c6486ffc1d9
Fix error in rethrow with anonymous functions (bug #61841).
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
605 if (! stack.isempty ()) |
8c6486ffc1d9
Fix error in rethrow with anonymous functions (bug #61841).
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
606 { |
8c6486ffc1d9
Fix error in rethrow with anonymous functions (bug #61841).
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
607 if (! (stack.contains ("file") && stack.contains ("name") |
8c6486ffc1d9
Fix error in rethrow with anonymous functions (bug #61841).
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
608 && stack.contains ("line"))) |
8c6486ffc1d9
Fix error in rethrow with anonymous functions (bug #61841).
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
609 error ("rethrow: STACK struct must contain the fields 'file', 'name', and 'line'"); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
610 |
30666
8c6486ffc1d9
Fix error in rethrow with anonymous functions (bug #61841).
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
611 if (! stack.contains ("column")) |
8c6486ffc1d9
Fix error in rethrow with anonymous functions (bug #61841).
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
612 { |
8c6486ffc1d9
Fix error in rethrow with anonymous functions (bug #61841).
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
613 octave_map new_stack = stack; |
8c6486ffc1d9
Fix error in rethrow with anonymous functions (bug #61841).
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
614 |
8c6486ffc1d9
Fix error in rethrow with anonymous functions (bug #61841).
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
615 new_stack.setfield ("column", Cell (octave_value (-1))); |
8c6486ffc1d9
Fix error in rethrow with anonymous functions (bug #61841).
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
616 |
8c6486ffc1d9
Fix error in rethrow with anonymous functions (bug #61841).
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
617 ee.set_stack_info (make_stack_frame_list (new_stack)); |
8c6486ffc1d9
Fix error in rethrow with anonymous functions (bug #61841).
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
618 } |
8c6486ffc1d9
Fix error in rethrow with anonymous functions (bug #61841).
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
619 else |
8c6486ffc1d9
Fix error in rethrow with anonymous functions (bug #61841).
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
620 ee.set_stack_info (make_stack_frame_list (stack)); |
8c6486ffc1d9
Fix error in rethrow with anonymous functions (bug #61841).
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
621 } |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
622 |
29171
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29117
diff
changeset
|
623 throw_error (ee); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
624 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
625 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
626 void error_system::vpanic (const char *fmt, va_list args) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
627 { |
27471 | 628 // Is there any point in trying to write the panic message to the |
629 // diary? | |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
630 |
27471 | 631 std::cerr << "panic: " << format_message (fmt, args) << std::endl; |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
632 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
633 abort (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
634 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
635 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
636 void error_system::panic (const char *fmt, ...) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
637 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
638 va_list args; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
639 va_start (args, fmt); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
640 vpanic (fmt, args); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
641 va_end (args); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
642 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
643 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
644 octave_scalar_map error_system::warning_query (const std::string& id_arg) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
645 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
646 octave_scalar_map retval; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
647 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
648 std::string id = id_arg; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
649 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
650 if (id == "last") |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
651 id = last_warning_id (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
652 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
653 octave_map opts = warning_options (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
654 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
655 Cell ident = opts.contents ("identifier"); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
656 Cell state = opts.contents ("state"); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
657 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
658 octave_idx_type nel = ident.numel (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
659 |
30723
08b08b7f05b2
Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753)
Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
parents:
30667
diff
changeset
|
660 panic_if (nel == 0); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
661 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
662 bool found = false; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
663 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
664 std::string val; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
665 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
666 for (octave_idx_type i = 0; i < nel; i++) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
667 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
668 if (ident(i).string_value () == id) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
669 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
670 val = state(i).string_value (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
671 found = true; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
672 break; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
673 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
674 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
675 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
676 if (! found) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
677 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
678 for (octave_idx_type i = 0; i < nel; i++) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
679 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
680 if (ident(i).string_value () == "all") |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
681 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
682 val = state(i).string_value (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
683 found = true; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
684 break; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
685 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
686 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
687 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
688 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
689 // The warning state "all" is always supposed to remain in the list, |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
690 // so we should always find a state, either explicitly or by using the |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
691 // state for "all". |
30723
08b08b7f05b2
Replace direct calls to C library assert() with Octave specialty functions in libinterp/ (bug #61753)
Arun Giridhar <arungiridhar@gmail.com> and Rik <rik@octave.org>
parents:
30667
diff
changeset
|
692 panic_unless (found); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
693 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
694 retval.assign ("identifier", id); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
695 retval.assign ("state", val); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
696 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
697 return retval; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
698 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
699 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
700 std::string error_system::default_warning_state (void) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
701 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
702 std::string retval = "on"; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
703 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
704 octave_map opts = warning_options (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
705 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
706 Cell ident = opts.contents ("identifier"); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
707 Cell state = opts.contents ("state"); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
708 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
709 octave_idx_type nel = ident.numel (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
710 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
711 for (octave_idx_type i = 0; i < nel; i++) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
712 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
713 if (ident(i).string_value () == "all") |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
714 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
715 retval = state(i).string_value (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
716 break; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
717 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
718 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
719 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
720 return retval; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
721 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
722 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
723 void error_system::display_warning_options (std::ostream& os) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
724 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
725 octave_map opts = warning_options (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
726 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
727 Cell ident = opts.contents ("identifier"); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
728 Cell state = opts.contents ("state"); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
729 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
730 octave_idx_type nel = ident.numel (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
731 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
732 std::string all_state = default_warning_state (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
733 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
734 if (all_state == "on") |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
735 os << "By default, warnings are enabled."; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
736 else if (all_state == "off") |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
737 os << "By default, warnings are disabled."; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
738 else if (all_state == "error") |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
739 os << "By default, warnings are treated as errors."; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
740 else |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
741 panic_impossible (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
742 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
743 if (nel > 1) |
28268
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
744 { |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
745 os << "\n"; |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
746 os << "Non-default warning states are:\n\n"; |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
747 os << " State Warning ID\n"; |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
748 } |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
749 |
28268
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
750 // The state for "all" is always supposed to be first in the list. |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
751 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
752 for (octave_idx_type i = 1; i < nel; i++) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
753 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
754 std::string tid = ident(i).string_value (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
755 std::string tst = state(i).string_value (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
756 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
757 os << std::setw (7) << tst << " " << tid << "\n"; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
758 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
759 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
760 os << std::endl; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
761 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
762 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
763 void error_system::set_warning_option (const std::string& state, |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
764 const std::string& ident) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
765 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
766 std::string all_state = default_warning_state (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
767 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
768 if (state != "on" && state != "off" && state != "error") |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
769 error ("invalid warning state: %s", state.c_str ()); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
770 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
771 octave_map opts = warning_options (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
772 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
773 Cell tid = opts.contents ("identifier"); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
774 Cell tst = opts.contents ("state"); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
775 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
776 octave_idx_type nel = tid.numel (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
777 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
778 for (octave_idx_type i = 0; i < nel; i++) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
779 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
780 if (tid(i).string_value () == ident) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
781 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
782 // We found it in the current list of options. If the state |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
783 // for "all" is same as arg1, we can simply remove the item |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
784 // from the list. |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
785 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
786 if (state == all_state && ident != "all") |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
787 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
788 for (i = i + 1; i < nel; i++) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
789 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
790 tid(i-1) = tid(i); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
791 tst(i-1) = tst(i); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
792 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
793 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
794 tid.resize (dim_vector (1, nel-1)); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
795 tst.resize (dim_vector (1, nel-1)); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
796 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
797 else |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
798 tst(i) = state; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
799 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
800 opts.clear (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
801 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
802 opts.assign ("identifier", tid); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
803 opts.assign ("state", tst); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
804 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
805 warning_options (opts); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
806 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
807 return; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
808 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
809 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
810 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
811 // The option wasn't already in the list. Append it. |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
812 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
813 tid.resize (dim_vector (1, nel+1)); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
814 tst.resize (dim_vector (1, nel+1)); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
815 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
816 tid(nel) = ident; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
817 tst(nel) = state; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
818 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
819 opts.clear (); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
820 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
821 opts.assign ("identifier", tid); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
822 opts.assign ("state", tst); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
823 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
824 warning_options (opts); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
825 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
826 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
827 void error_system::disable_warning (const std::string& id) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
828 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
829 set_warning_option ("off", id); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
830 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
831 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
832 void error_system::initialize_default_warning_state (void) |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
833 { |
27471 | 834 warning_options (init_warning_options ("on")); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
835 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
836 // Most people will want to have the following disabled. |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
837 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
838 disable_warning ("Octave:array-as-logical"); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
839 disable_warning ("Octave:array-to-scalar"); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
840 disable_warning ("Octave:array-to-vector"); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
841 disable_warning ("Octave:imag-to-real"); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
842 disable_warning ("Octave:language-extension"); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
843 disable_warning ("Octave:missing-semicolon"); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
844 disable_warning ("Octave:neg-dim-as-zero"); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
845 disable_warning ("Octave:separator-insert"); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
846 disable_warning ("Octave:single-quote-string"); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
847 disable_warning ("Octave:str-to-num"); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
848 disable_warning ("Octave:mixed-string-concat"); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
849 disable_warning ("Octave:variable-switch-label"); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
850 } |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
851 |
27471 | 852 void error_system::interpreter_try (unwind_protect& frame) |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
853 { |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
854 frame.protect_var (m_debug_on_error); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
855 m_debug_on_error = false; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
856 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
857 frame.protect_var (m_debug_on_warning); |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
858 m_debug_on_warning = false; |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
859 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
860 // Leave debug_on_caught as it was, so errors in try/catch are still |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
861 // caught. |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
862 } |
27471 | 863 |
864 void error_system::throw_error (const std::string& err_type, | |
865 const std::string& id, | |
866 const std::string& message, | |
867 const std::list<frame_info>& stack_info_arg) | |
868 { | |
869 std::list<frame_info> stack_info = stack_info_arg; | |
870 | |
871 if (stack_info.empty ()) | |
872 { | |
873 tree_evaluator& tw = m_interpreter.get_evaluator (); | |
874 | |
875 stack_info = tw.backtrace_info (); | |
19421
8b785ca93de7
don't print stack trace on errors if error_state is -2
John W. Eaton <jwe@octave.org>
parents:
19415
diff
changeset
|
876 |
27471 | 877 // Print the error message only if it is different from the |
878 // previous one; makes the output more concise and readable. | |
879 | |
880 stack_info.unique (); | |
881 } | |
882 | |
883 execution_exception ex (err_type, id, message, stack_info); | |
884 | |
885 throw_error (ex); | |
886 } | |
887 | |
888 void error_system::throw_error (execution_exception& ex) | |
889 { | |
890 throw ex; | |
891 } | |
20780
92958b1ee100
restore stack traces to error messages
John W. Eaton <jwe@octave.org>
parents:
20777
diff
changeset
|
892 |
29171
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29117
diff
changeset
|
893 void error_system::save_exception (const execution_exception& ee) |
27471 | 894 { |
29171
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29117
diff
changeset
|
895 last_error_id (ee.identifier ()); |
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29117
diff
changeset
|
896 std::string message = ee.message (); |
27471 | 897 std::string xmsg |
898 = (message.size () > 0 && message.back () == '\n' | |
899 ? message.substr (0, message.size () - 1) : message); | |
900 last_error_message (xmsg); | |
29171
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29117
diff
changeset
|
901 last_error_stack (make_stack_map (ee.stack_info ())); |
27471 | 902 } |
20780
92958b1ee100
restore stack traces to error messages
John W. Eaton <jwe@octave.org>
parents:
20777
diff
changeset
|
903 |
29501
220c6c4a3533
leave error message output stream decision to error_system class
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
904 // DEPRECATED in Octave 7. |
29171
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29117
diff
changeset
|
905 void error_system::display_exception (const execution_exception& ee, |
27471 | 906 std::ostream& os) const |
907 { | |
908 if (m_beep_on_error) | |
909 os << "\a"; | |
910 | |
29171
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29117
diff
changeset
|
911 ee.display (octave_diary); |
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29117
diff
changeset
|
912 ee.display (os); |
27471 | 913 } |
29501
220c6c4a3533
leave error message output stream decision to error_system class
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
914 |
220c6c4a3533
leave error message output stream decision to error_system class
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
915 void error_system::display_exception (const execution_exception& ee) const |
220c6c4a3533
leave error message output stream decision to error_system class
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
916 { |
29502
76fdbe78884f
allow event manager to handle display of execution exceptions
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
917 // FIXME: How should we handle beep_on_error? |
29501
220c6c4a3533
leave error message output stream decision to error_system class
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
918 |
220c6c4a3533
leave error message output stream decision to error_system class
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
919 ee.display (octave_diary); |
220c6c4a3533
leave error message output stream decision to error_system class
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
920 |
220c6c4a3533
leave error message output stream decision to error_system class
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
921 // FIXME: Handle display using an event manager message so that the |
220c6c4a3533
leave error message output stream decision to error_system class
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
922 // GUI or other client can receive error messages without needing to |
220c6c4a3533
leave error message output stream decision to error_system class
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
923 // capture them from std::cerr or some other stream. |
220c6c4a3533
leave error message output stream decision to error_system class
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
924 |
29502
76fdbe78884f
allow event manager to handle display of execution exceptions
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
925 event_manager& evmgr = m_interpreter.get_event_manager (); |
76fdbe78884f
allow event manager to handle display of execution exceptions
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
926 |
76fdbe78884f
allow event manager to handle display of execution exceptions
John W. Eaton <jwe@octave.org>
parents:
29501
diff
changeset
|
927 evmgr.display_exception (ee, m_beep_on_error); |
27471 | 928 } |
29960
939bef0b66e0
merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents:
29958
diff
changeset
|
929 |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31577
diff
changeset
|
930 OCTAVE_END_NAMESPACE(octave) |
20780
92958b1ee100
restore stack traces to error messages
John W. Eaton <jwe@octave.org>
parents:
20777
diff
changeset
|
931 |
1 | 932 void |
6338 | 933 vmessage (const char *name, const char *fmt, va_list args) |
934 { | |
27471 | 935 std::string message; |
936 | |
937 if (name) | |
938 message = std::string (name) + ": "; | |
939 | |
940 message += format_message (fmt, args); | |
941 | |
942 octave_diary << message << std::endl; | |
943 std::cerr << message << std::endl; | |
6338 | 944 } |
945 | |
946 void | |
1 | 947 message (const char *name, const char *fmt, ...) |
948 { | |
949 va_list args; | |
950 va_start (args, fmt); | |
6338 | 951 vmessage (name, fmt, args); |
1 | 952 va_end (args); |
953 } | |
954 | |
955 void | |
6338 | 956 vusage_with_id (const char *id, const char *fmt, va_list args) |
957 { | |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30896
diff
changeset
|
958 octave::error_system& es = octave::__get_error_system__ (); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
959 |
27471 | 960 es.vusage (id, fmt, args); |
6338 | 961 } |
962 | |
963 void | |
5567 | 964 usage_with_id (const char *id, const char *fmt, ...) |
965 { | |
966 va_list args; | |
967 va_start (args, fmt); | |
6338 | 968 vusage_with_id (id, fmt, args); |
1 | 969 va_end (args); |
970 } | |
971 | |
6000 | 972 void |
6338 | 973 verror (const char *fmt, va_list args) |
974 { | |
27471 | 975 error_1 ("", fmt, args); |
6338 | 976 } |
977 | |
978 void | |
6000 | 979 error (const char *fmt, ...) |
980 { | |
981 va_list args; | |
982 va_start (args, fmt); | |
6338 | 983 verror (fmt, args); |
6000 | 984 va_end (args); |
985 } | |
986 | |
987 void | |
29171
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29117
diff
changeset
|
988 verror (octave::execution_exception& ee, const char *fmt, va_list args) |
20756
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
989 { |
29171
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29117
diff
changeset
|
990 error_1 (ee, "", fmt, args); |
20756
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
991 } |
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
992 |
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
993 void |
29171
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29117
diff
changeset
|
994 error (octave::execution_exception& ee, const char *fmt, ...) |
20756
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
995 { |
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
996 va_list args; |
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
997 va_start (args, fmt); |
29171
254ee9af5014
maint: More updates to standardize exception naming scheme.
Rik <rik@octave.org>
parents:
29117
diff
changeset
|
998 verror (ee, fmt, args); |
20756
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
999 va_end (args); |
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
1000 } |
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
1001 |
200ae1d650b7
propagate octave_execution_exception objects through try/catch blocks
John W. Eaton <jwe@octave.org>
parents:
20711
diff
changeset
|
1002 void |
9753
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1003 verror_with_cfn (const char *fmt, va_list args) |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1004 { |
27471 | 1005 error_1 ("", fmt, args); |
9753
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1006 } |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1007 |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1008 void |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1009 error_with_cfn (const char *fmt, ...) |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1010 { |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1011 va_list args; |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1012 va_start (args, fmt); |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1013 verror_with_cfn (fmt, args); |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1014 va_end (args); |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1015 } |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1016 |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1017 void |
6338 | 1018 verror_with_id (const char *id, const char *fmt, va_list args) |
1019 { | |
27471 | 1020 error_1 (id, fmt, args); |
6338 | 1021 } |
1022 | |
1023 void | |
6000 | 1024 error_with_id (const char *id, const char *fmt, ...) |
1025 { | |
1026 va_list args; | |
1027 va_start (args, fmt); | |
6338 | 1028 verror_with_id (id, fmt, args); |
6000 | 1029 va_end (args); |
1030 } | |
1031 | |
9753
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1032 void |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1033 verror_with_id_cfn (const char *id, const char *fmt, va_list args) |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1034 { |
27471 | 1035 error_1 (id, fmt, args); |
9753
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1036 } |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1037 |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1038 void |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1039 error_with_id_cfn (const char *id, const char *fmt, ...) |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1040 { |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1041 va_list args; |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1042 va_start (args, fmt); |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1043 verror_with_id_cfn (id, fmt, args); |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1044 va_end (args); |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1045 } |
892e2aa7bc75
improve error messages by auto-prepending current function name
Jaroslav Hajek <highegg@gmail.com>
parents:
9675
diff
changeset
|
1046 |
1 | 1047 void |
6338 | 1048 vwarning (const char *fmt, va_list args) |
1049 { | |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
1050 vwarning ("", fmt, args); |
6338 | 1051 } |
1052 | |
1053 void | |
5567 | 1054 warning (const char *fmt, ...) |
1055 { | |
1056 va_list args; | |
1057 va_start (args, fmt); | |
6338 | 1058 vwarning (fmt, args); |
5567 | 1059 va_end (args); |
1060 } | |
1061 | |
1062 void | |
6338 | 1063 vwarning_with_id (const char *id, const char *fmt, va_list args) |
1064 { | |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
1065 vwarning (id, fmt, args); |
6338 | 1066 } |
1067 | |
1068 void | |
5567 | 1069 warning_with_id (const char *id, const char *fmt, ...) |
1070 { | |
1071 va_list args; | |
1072 va_start (args, fmt); | |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
1073 vwarning (id, fmt, args); |
5567 | 1074 va_end (args); |
1075 } | |
1076 | |
1077 void | |
6338 | 1078 vparse_error (const char *fmt, va_list args) |
1079 { | |
27471 | 1080 error_1 ("", fmt, args); |
6338 | 1081 } |
1082 | |
1083 void | |
1005 | 1084 parse_error (const char *fmt, ...) |
1085 { | |
1086 va_list args; | |
1087 va_start (args, fmt); | |
6338 | 1088 vparse_error (fmt, args); |
5567 | 1089 va_end (args); |
1090 } | |
1091 | |
1092 void | |
6338 | 1093 vparse_error_with_id (const char *id, const char *fmt, va_list args) |
1094 { | |
27471 | 1095 error_1 (id, fmt, args); |
6338 | 1096 } |
1097 | |
1098 void | |
5567 | 1099 parse_error_with_id (const char *id, const char *fmt, ...) |
1100 { | |
1101 va_list args; | |
1102 va_start (args, fmt); | |
6338 | 1103 vparse_error_with_id (id, fmt, args); |
1 | 1104 va_end (args); |
1105 } | |
1106 | |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
1107 OCTAVE_NORETURN |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
1108 void |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
1109 vpanic (const char *fmt, va_list args) |
22808
1d3d0321bc5d
preserve lasterror info on rethrow (bug #49642)
John W. Eaton <jwe@octave.org>
parents:
22489
diff
changeset
|
1110 { |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30896
diff
changeset
|
1111 octave::error_system& es = octave::__get_error_system__ (); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
1112 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
1113 es.vpanic (fmt, args); |
22808
1d3d0321bc5d
preserve lasterror info on rethrow (bug #49642)
John W. Eaton <jwe@octave.org>
parents:
22489
diff
changeset
|
1114 } |
1d3d0321bc5d
preserve lasterror info on rethrow (bug #49642)
John W. Eaton <jwe@octave.org>
parents:
22489
diff
changeset
|
1115 |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
1116 OCTAVE_NORETURN |
6361 | 1117 void |
1 | 1118 panic (const char *fmt, ...) |
1119 { | |
1120 va_list args; | |
1121 va_start (args, fmt); | |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
1122 vpanic (fmt, args); |
4732 | 1123 va_end (args); |
1124 } | |
1125 | |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31577
diff
changeset
|
1126 OCTAVE_BEGIN_NAMESPACE(octave) |
29956
a956ca6698d2
move some error handling functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29951
diff
changeset
|
1127 |
4732 | 1128 void |
1129 defun_usage_message (const std::string& msg) | |
1130 { | |
29956
a956ca6698d2
move some error handling functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29951
diff
changeset
|
1131 ::defun_usage_message ("%s", msg.c_str ()); |
528 | 1132 } |
1133 | |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1134 DEFMETHOD (rethrow, interp, args, , |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1135 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1136 @deftypefn {} {} rethrow (@var{err}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1137 Reissue a previous error as defined by @var{err}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1138 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1139 @var{err} is a structure that must contain at least the @qcode{"message"} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1140 and @qcode{"identifier"} fields. @var{err} can also contain a field |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1141 @qcode{"stack"} that gives information on the assumed location of the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1142 error. Typically @var{err} is returned from @code{lasterror}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1143 @seealso{lasterror, lasterr, error} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1144 @end deftypefn */) |
6361 | 1145 { |
20819
f428cbe7576f
eliminate unnecessary uses of nargin
John W. Eaton <jwe@octave.org>
parents:
20817
diff
changeset
|
1146 if (args.length () != 1) |
6959 | 1147 print_usage (); |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1148 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1149 const octave_scalar_map err = args(0).scalar_map_value (); |
6361 | 1150 |
22808
1d3d0321bc5d
preserve lasterror info on rethrow (bug #49642)
John W. Eaton <jwe@octave.org>
parents:
22489
diff
changeset
|
1151 if (! (err.contains ("message") && err.contains ("identifier"))) |
1d3d0321bc5d
preserve lasterror info on rethrow (bug #49642)
John W. Eaton <jwe@octave.org>
parents:
22489
diff
changeset
|
1152 error ("rethrow: ERR struct must contain the fields 'message' and 'identifier'"); |
9166
69088b7b139c
use complete stack trace information for lasterror
John W. Eaton <jwe@octave.org>
parents:
9153
diff
changeset
|
1153 |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20897
diff
changeset
|
1154 std::string msg = err.contents ("message").string_value (); |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20897
diff
changeset
|
1155 std::string id = err.contents ("identifier").string_value (); |
6483 | 1156 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1157 octave_map err_stack = init_error_stack (interp); |
6483 | 1158 |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20897
diff
changeset
|
1159 if (err.contains ("stack")) |
22808
1d3d0321bc5d
preserve lasterror info on rethrow (bug #49642)
John W. Eaton <jwe@octave.org>
parents:
22489
diff
changeset
|
1160 err_stack = err.contents ("stack").xmap_value ("ERR.STACK must be a struct"); |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20897
diff
changeset
|
1161 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1162 error_system& es = interp.get_error_system (); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
1163 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
1164 es.rethrow_error (id, msg, err_stack); |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1165 |
21078
49852ff04747
maint: Remove unnecessary declarations of retval.
Rik <rik@octave.org>
parents:
21040
diff
changeset
|
1166 return ovl (); |
6361 | 1167 } |
1168 | |
27471 | 1169 DEFMETHOD (error, interp, args, , |
1170 doc: /* -*- texinfo -*- | |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1171 @deftypefn {} {} error (@var{template}, @dots{}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1172 @deftypefnx {} {} error (@var{id}, @var{template}, @dots{}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1173 Display an error message and stop m-file execution. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1174 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1175 Format the optional arguments under the control of the template string |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1176 @var{template} using the same rules as the @code{printf} family of |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1177 functions (@pxref{Formatted Output}) and print the resulting message |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1178 on the @code{stderr} stream. The message is prefixed by the character |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1179 string @samp{error: }. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1180 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1181 Calling @code{error} also sets Octave's internal error state such that |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1182 control will return to the top level without evaluating any further |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1183 commands. This is useful for aborting from functions or scripts. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1184 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1185 If the error message does not end with a newline character, Octave will |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1186 print a traceback of all the function calls leading to the error. For |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1187 example, given the following function definitions: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1188 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1189 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1190 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1191 function f () g (); end |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1192 function g () h (); end |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1193 function h () nargin == 1 || error ("nargin != 1"); end |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1194 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1195 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1196 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1197 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1198 calling the function @code{f} will result in a list of messages that |
22808
1d3d0321bc5d
preserve lasterror info on rethrow (bug #49642)
John W. Eaton <jwe@octave.org>
parents:
22489
diff
changeset
|
1199 can help you to quickly find the exact location of the error: |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1200 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1201 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1202 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1203 f () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1204 error: nargin != 1 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1205 error: called from: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1206 error: h at line 1, column 27 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1207 error: g at line 1, column 15 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1208 error: f at line 1, column 15 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1209 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1210 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1211 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1212 If the error message ends in a newline character, Octave will print the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1213 message but will not display any traceback messages as it returns |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1214 control to the top level. For example, modifying the error message |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1215 in the previous example to end in a newline causes Octave to only print |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1216 a single message: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1217 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1218 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1219 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1220 function h () nargin == 1 || error ("nargin != 1\n"); end |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1221 f () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1222 error: nargin != 1 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1223 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1224 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1225 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1226 A null string ("") input to @code{error} will be ignored and the code |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1227 will continue running as if the statement were a NOP@. This is for |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1228 compatibility with @sc{matlab}. It also makes it possible to write code |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1229 such as |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1230 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1231 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1232 @group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1233 err_msg = ""; |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1234 if (CONDITION 1) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1235 err_msg = "CONDITION 1 found"; |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1236 elseif (CONDITION2) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1237 err_msg = "CONDITION 2 found"; |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1238 @dots{} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1239 endif |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1240 error (err_msg); |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1241 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1242 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1243 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1244 @noindent |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1245 which will only stop execution if an error has been found. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1246 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1247 Implementation Note: For compatibility with @sc{matlab}, escape |
29117
10a35049bad7
doc: Cleanup Texinfo macros use in documentation.
Rik <rik@octave.org>
parents:
28981
diff
changeset
|
1248 sequences in @var{template} (e.g., @qcode{"@backslashchar{}n"} => |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1249 newline) are processed regardless of whether @var{template} has been defined |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1250 with single quotes, as long as there are two or more input arguments. To |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1251 disable escape sequence expansion use a second backslash before the sequence |
29117
10a35049bad7
doc: Cleanup Texinfo macros use in documentation.
Rik <rik@octave.org>
parents:
28981
diff
changeset
|
1252 (e.g., @qcode{"@backslashchar{}@backslashchar{}n"}) or use the |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1253 @code{regexptranslate} function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1254 @seealso{warning, lasterror} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1255 @end deftypefn */) |
897 | 1256 { |
7252 | 1257 int nargin = args.length (); |
1258 | |
20918
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20897
diff
changeset
|
1259 if (nargin == 0) |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20897
diff
changeset
|
1260 print_usage (); |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20897
diff
changeset
|
1261 |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20897
diff
changeset
|
1262 octave_value retval; |
6f0bd96f93c0
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20897
diff
changeset
|
1263 |
7252 | 1264 std::string id; |
27471 | 1265 std::string message; |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1266 std::list<frame_info> stack_info; |
7252 | 1267 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1268 bool have_fmt = false; |
5567 | 1269 |
23584
7ed6b258db91
maint: Deprecate is_map and replace with isstruct.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
1270 if (nargin == 1 && args(0).isstruct ()) |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1271 { |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1272 // empty struct is not an error. return and resume calling function. |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23573
diff
changeset
|
1273 if (args(0).isempty ()) |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1274 return retval; |
13709
a0875c6cab7e
error.cc: Don't complain if error struct input is empty (Matlab compatability)
Rik <octave@nomad.inbox5.com>
parents:
12705
diff
changeset
|
1275 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1276 octave_scalar_map m = args(0).scalar_map_value (); |
7252 | 1277 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1278 // empty struct is not an error. return and resume calling function. |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1279 if (m.nfields () == 0) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1280 return retval; |
7252 | 1281 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1282 if (m.contains ("message")) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1283 { |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1284 octave_value c = m.getfield ("message"); |
9675
ef45d191d833
error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents:
9588
diff
changeset
|
1285 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1286 if (c.is_string ()) |
27471 | 1287 message = c.string_value (); |
14558
0c9c85e702ca
better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents:
14361
diff
changeset
|
1288 } |
0c9c85e702ca
better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents:
14361
diff
changeset
|
1289 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1290 if (m.contains ("identifier")) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1291 { |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1292 octave_value c = m.getfield ("identifier"); |
7252 | 1293 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1294 if (c.is_string ()) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1295 id = c.string_value (); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1296 } |
9675
ef45d191d833
error: improve compatibility for calls with no arguments or empty format
John W. Eaton <jwe@octave.org>
parents:
9588
diff
changeset
|
1297 |
27471 | 1298 if (m.contains ("stack")) |
1299 { | |
1300 octave_value c = m.getfield ("stack"); | |
1301 | |
1302 if (c.isstruct ()) | |
27472
c0883bfc0f36
simplify evaluator logic for try-catch command
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
1303 stack_info |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1304 = error_system::make_stack_frame_list (c.map_value ()); |
27471 | 1305 } |
7252 | 1306 } |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1307 else |
27471 | 1308 { |
1309 octave_value_list nargs = args; | |
1310 | |
1311 have_fmt = maybe_extract_message_id ("error", args, nargs, id); | |
1312 | |
1313 if (nargs.length () == 0) | |
1314 message = "unspecified error"; | |
1315 else | |
1316 { | |
1317 octave_value arg; | |
14558
0c9c85e702ca
better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents:
14361
diff
changeset
|
1318 |
27471 | 1319 if (have_fmt) |
1320 { | |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1321 octave_value_list tmp = Fsprintf (nargs, 1); |
27471 | 1322 arg = tmp(0); |
1323 } | |
1324 else | |
1325 arg = nargs(0); | |
1326 | |
1327 if (arg.is_defined ()) | |
1328 { | |
1329 if (arg.isempty ()) | |
1330 message = ""; | |
1331 else if (arg.is_string ()) | |
1332 message = arg.string_value (); | |
1333 } | |
1334 } | |
1335 } | |
1336 | |
1337 if (message.empty ()) | |
1338 return retval; | |
1339 | |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1340 error_system& es = interp.get_error_system (); |
27471 | 1341 |
1342 es.throw_error ("error", id, message, stack_info); | |
7252 | 1343 |
3934 | 1344 return retval; |
1489 | 1345 } |
897 | 1346 |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23465
diff
changeset
|
1347 DEFMETHOD (warning, interp, args, nargout, |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23465
diff
changeset
|
1348 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1349 @deftypefn {} {} warning (@var{template}, @dots{}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1350 @deftypefnx {} {} warning (@var{id}, @var{template}, @dots{}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1351 @deftypefnx {} {} warning ("on", @var{id}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1352 @deftypefnx {} {} warning ("off", @var{id}) |
24047
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1353 @deftypefnx {} {} warning ("error", @var{id}) |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1354 @deftypefnx {} {} warning ("query", @var{id}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1355 @deftypefnx {} {} warning (@var{state}, @var{id}, "local") |
25215
7ca5f8c70879
doc: Update docstring for warning().
Rik <rik@octave.org>
parents:
25164
diff
changeset
|
1356 @deftypefnx {} {} warning (@var{warning_struct}) |
7ca5f8c70879
doc: Update docstring for warning().
Rik <rik@octave.org>
parents:
25164
diff
changeset
|
1357 @deftypefnx {} {@var{warning_struct} =} warning (@dots{}) |
25588
5f63ca41eacb
doc: Remove bad calling convention for warning with a mode struct (bug #54288)
Rik <rik@octave.org>
parents:
25579
diff
changeset
|
1358 @deftypefnx {} {} warning (@var{state}, @var{mode}) |
24047
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1359 |
25215
7ca5f8c70879
doc: Update docstring for warning().
Rik <rik@octave.org>
parents:
25164
diff
changeset
|
1360 Display a warning message or control the behavior of Octave's warning system. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1361 |
25215
7ca5f8c70879
doc: Update docstring for warning().
Rik <rik@octave.org>
parents:
25164
diff
changeset
|
1362 The first call form uses a template @var{template} and optional additional |
7ca5f8c70879
doc: Update docstring for warning().
Rik <rik@octave.org>
parents:
25164
diff
changeset
|
1363 arguments to display a message on the @code{stderr} stream. The message is |
7ca5f8c70879
doc: Update docstring for warning().
Rik <rik@octave.org>
parents:
25164
diff
changeset
|
1364 formatted using the same rules as the @code{printf} family of functions |
7ca5f8c70879
doc: Update docstring for warning().
Rik <rik@octave.org>
parents:
25164
diff
changeset
|
1365 (@pxref{Formatted Output}) and prefixed by the character string |
7ca5f8c70879
doc: Update docstring for warning().
Rik <rik@octave.org>
parents:
25164
diff
changeset
|
1366 @w{@samp{warning: }}. You should use this function when you want to notify the |
7ca5f8c70879
doc: Update docstring for warning().
Rik <rik@octave.org>
parents:
25164
diff
changeset
|
1367 user of an unusual condition, but only when it makes sense for your program to |
7ca5f8c70879
doc: Update docstring for warning().
Rik <rik@octave.org>
parents:
25164
diff
changeset
|
1368 go on. For example: |
24047
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1369 |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1370 @example |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1371 @group |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1372 warning ("foo: maybe something wrong here"); |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1373 @end group |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1374 @end example |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1375 |
26859
b4a9888bb3c9
doc: document the newline character in warning messages (bug #49158)
Mike Miller <mtmiller@octave.org>
parents:
26617
diff
changeset
|
1376 If the warning message does not end with a newline character, Octave will |
b4a9888bb3c9
doc: document the newline character in warning messages (bug #49158)
Mike Miller <mtmiller@octave.org>
parents:
26617
diff
changeset
|
1377 print a traceback of all the function calls leading to the warning. If the |
b4a9888bb3c9
doc: document the newline character in warning messages (bug #49158)
Mike Miller <mtmiller@octave.org>
parents:
26617
diff
changeset
|
1378 warning message does end in a newline character, Octave will suppress the |
b4a9888bb3c9
doc: document the newline character in warning messages (bug #49158)
Mike Miller <mtmiller@octave.org>
parents:
26617
diff
changeset
|
1379 traceback messages as it returns control to the top level. For more details |
30377
26f2daafa270
doc: Use consistent styling for @ref, @xref, @pxref statements.
Rik <rik@octave.org>
parents:
29961
diff
changeset
|
1380 and examples, @pxref{XREFerror,,@code{error}}. |
26859
b4a9888bb3c9
doc: document the newline character in warning messages (bug #49158)
Mike Miller <mtmiller@octave.org>
parents:
26617
diff
changeset
|
1381 |
24047
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1382 The optional warning identifier @var{id} allows users to enable or disable |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1383 warnings tagged by this identifier. A message identifier is a string of the |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1384 form @qcode{"NAMESPACE:WARNING-NAME"}. Octave's own warnings use the |
28961
d9d028b479ac
doc: Use @code{} within alternate text for @xref,@pxref macros in libinterp/
Rik <rik@octave.org>
parents:
28857
diff
changeset
|
1385 @qcode{"Octave"} namespace (@pxref{XREFwarning_ids,,@code{warning_ids}}). For |
24441 | 1386 example: |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1387 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1388 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1389 @group |
24047
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1390 warning ("MyNameSpace:check-something", |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1391 "foo: maybe something wrong here"); |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1392 @end group |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1393 @end example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1394 |
24047
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1395 The second call form is meant to change and/or query the state of warnings. |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1396 The first input argument must be a string @var{state} (@qcode{"on"}, |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1397 @qcode{"off"}, @qcode{"error"}, or @qcode{"query"}) followed by an optional |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1398 warning identifier @var{id} or @qcode{"all"} (default). |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1399 |
25215
7ca5f8c70879
doc: Update docstring for warning().
Rik <rik@octave.org>
parents:
25164
diff
changeset
|
1400 The optional output argument @var{warning_struct} is a structure or structure |
7ca5f8c70879
doc: Update docstring for warning().
Rik <rik@octave.org>
parents:
25164
diff
changeset
|
1401 array with fields @qcode{"state"} and @qcode{"identifier"}. The @var{state} |
7ca5f8c70879
doc: Update docstring for warning().
Rik <rik@octave.org>
parents:
25164
diff
changeset
|
1402 argument may have the following values: |
24047
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1403 |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1404 @table @asis |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1405 @item @qcode{"on"}|@qcode{"off"}: |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1406 Enable or disable the display of warnings identified by @var{id} and optionally |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1407 return their previous state @var{stout}. |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1408 |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1409 @item @qcode{"error"}: |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1410 Turn warnings identified by @var{id} into errors and optionally return their |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1411 previous state @var{stout}. |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1412 |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1413 @item @qcode{"query"}: |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1414 Return the current state of warnings identified by @var{id}. |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1415 @end table |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1416 |
25215
7ca5f8c70879
doc: Update docstring for warning().
Rik <rik@octave.org>
parents:
25164
diff
changeset
|
1417 A structure or structure array @var{warning_struct}, with fields |
7ca5f8c70879
doc: Update docstring for warning().
Rik <rik@octave.org>
parents:
25164
diff
changeset
|
1418 @qcode{"state"} and @qcode{"identifier"}, may be given as an input to achieve |
7ca5f8c70879
doc: Update docstring for warning().
Rik <rik@octave.org>
parents:
25164
diff
changeset
|
1419 equivalent results. The following example shows how to temporarily disable a |
7ca5f8c70879
doc: Update docstring for warning().
Rik <rik@octave.org>
parents:
25164
diff
changeset
|
1420 warning and then restore its original state: |
24047
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1421 |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1422 @example |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1423 @group |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1424 loglog (-1:10); |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1425 ## Disable the previous warning and save its original state |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1426 [~, id] = lastwarn (); |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1427 warnstate = warning ("off", id); |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1428 loglog (-1:10); |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1429 ## Restore its original state |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1430 warning (warnstate); |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1431 @end group |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1432 @end example |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1433 |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1434 If a final argument @qcode{"local"} is provided then the warning state will be |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1435 set temporarily until the end of the current function. Changes to warning |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1436 states that are set locally affect the current function and all functions |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1437 called from the current scope. The previous warning state is restored on |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1438 return from the current function. The @qcode{"local"} option is ignored if |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1439 used in the top-level workspace. |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1440 |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1441 With no input argument @code{warning ()} is equivalent to |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1442 @code{warning ("query", "all")} except that in the absence of an output |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1443 argument, the state of warnings is displayed on @code{stderr}. |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1444 |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1445 The level of verbosity of the warning system may also be controlled by two |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1446 modes @var{mode}: |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1447 |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1448 @table @asis |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1449 @item @qcode{"backtrace"}: |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1450 enable/disable the display of the stack trace after the warning message |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1451 |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1452 @item @qcode{"verbose"}: |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1453 enable/disable the display of additional information after the warning message |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1454 @end table |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1455 |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1456 In this case the @var{state} argument may only be @qcode{"on"} or |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1457 @qcode{"off"}. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1458 |
25215
7ca5f8c70879
doc: Update docstring for warning().
Rik <rik@octave.org>
parents:
25164
diff
changeset
|
1459 Implementation Note: For compatibility with @sc{matlab}, escape sequences in |
29117
10a35049bad7
doc: Cleanup Texinfo macros use in documentation.
Rik <rik@octave.org>
parents:
28981
diff
changeset
|
1460 @var{template} (e.g., @qcode{"@backslashchar{}n"} => newline) are processed |
25215
7ca5f8c70879
doc: Update docstring for warning().
Rik <rik@octave.org>
parents:
25164
diff
changeset
|
1461 regardless of whether @var{template} has been defined with single quotes, as |
7ca5f8c70879
doc: Update docstring for warning().
Rik <rik@octave.org>
parents:
25164
diff
changeset
|
1462 long as there are two or more input arguments. To disable escape sequence |
7ca5f8c70879
doc: Update docstring for warning().
Rik <rik@octave.org>
parents:
25164
diff
changeset
|
1463 expansion use a second backslash before the sequence (e.g., |
29117
10a35049bad7
doc: Cleanup Texinfo macros use in documentation.
Rik <rik@octave.org>
parents:
28981
diff
changeset
|
1464 @qcode{"@backslashchar{}@backslashchar{}n"}) or use the |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1465 @code{regexptranslate} function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1466 @seealso{warning_ids, lastwarn, error} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1467 @end deftypefn */) |
1489 | 1468 { |
5567 | 1469 octave_value retval; |
3934 | 1470 |
5567 | 1471 int nargin = args.length (); |
3935 | 1472 bool done = false; |
3934 | 1473 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1474 error_system& es = interp.get_error_system (); |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1475 |
20897
9aad16a799c9
maint: Replace argc variable name with nargin in C++ code.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1476 if (nargin > 0 && args.all_strings_p ()) |
3935 | 1477 { |
1478 string_vector argv = args.make_argv ("warning"); | |
1479 | |
20996 | 1480 std::string arg1 = argv[1]; |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1481 std::transform (arg1.begin (), arg1.end (), arg1.begin (), tolower); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1482 std::string arg2 = "all"; |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1483 std::string arg2_lc = "all"; |
5567 | 1484 |
20897
9aad16a799c9
maint: Replace argc variable name with nargin in C++ code.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1485 if (nargin >= 2) |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1486 { |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1487 arg2 = argv[2]; |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1488 arg2_lc = arg2; |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1489 std::transform (arg2_lc.begin (), arg2_lc.end (), arg2_lc.begin (), |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1490 tolower); |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1491 } |
5567 | 1492 |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1493 if (arg1 == "on" || arg1 == "off" || arg1 == "error") |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1494 { |
24047
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1495 // Prepare output structure |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1496 octave_map old_warning_options; |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1497 if (arg2_lc == "all") |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1498 old_warning_options = es.warning_options (); |
24047
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1499 else |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
1500 old_warning_options = octave_map (es.warning_query (arg2)); |
15427
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1501 |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1502 if (nargin == 3) |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1503 { |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1504 std::string arg3_lc = argv[3]; |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1505 std::transform (arg3_lc.begin (), arg3_lc.end (), |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1506 arg3_lc.begin (), tolower); |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1507 if (arg3_lc == "local" && ! interp.at_top_level ()) |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1508 { |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1509 octave_scalar_map val = es.warning_query (arg2); |
15427
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1510 |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1511 octave_value curr_state = val.contents ("state"); |
26661
cf9e10ce3351
move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents:
26619
diff
changeset
|
1512 |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1513 // FIXME: this might be better with a dictionary object. |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1514 tree_evaluator& tw = interp.get_evaluator (); |
15427
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1515 |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1516 octave_value curr_warning_states |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1517 = tw.get_auto_fcn_var (stack_frame::SAVED_WARNING_STATES); |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1518 |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1519 octave_map m; |
15427
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1520 |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1521 if (curr_warning_states.is_defined ()) |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1522 m = curr_warning_states.map_value (); |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1523 else |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1524 { |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1525 string_vector fields (2); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1526 |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1527 fields(0) = "identifier"; |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1528 fields(1) = "state"; |
15427
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1529 |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1530 m = octave_map (dim_vector (0, 1), fields); |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1531 } |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1532 |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1533 Cell ids = m.contents ("identifier"); |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1534 Cell states = m.contents ("state"); |
15427
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1535 |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1536 octave_idx_type nel = states.numel (); |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1537 bool found = false; |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1538 octave_idx_type i; |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1539 for (i = 0; i < nel; i++) |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1540 { |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1541 std::string id = ids(i).string_value (); |
15427
6823ad7a25b1
implement local option for warnings
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
1542 |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1543 if (id == arg2) |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1544 { |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1545 states(i) = curr_state; |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1546 found = true; |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1547 break; |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1548 } |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1549 } |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1550 |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1551 if (! found) |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1552 { |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1553 m.resize (dim_vector (nel+1, 1)); |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1554 |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1555 ids.resize (dim_vector (nel+1, 1)); |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1556 states.resize (dim_vector (nel+1, 1)); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1557 |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1558 ids(nel) = arg2; |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1559 states(nel) = curr_state; |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1560 } |
3934 | 1561 |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1562 m.contents ("identifier") = ids; |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1563 m.contents ("state") = states; |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1564 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1565 tw.set_auto_fcn_var (stack_frame::SAVED_WARNING_STATES, m); |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1566 |
28271
5e1f4060289a
Make 1-input form "warning (STATE)" use special ID "all" (bug #58296).
Rik <rik@octave.org>
parents:
28268
diff
changeset
|
1567 // Now ignore the "local" argument, |
5e1f4060289a
Make 1-input form "warning (STATE)" use special ID "all" (bug #58296).
Rik <rik@octave.org>
parents:
28268
diff
changeset
|
1568 // and continue to handle the current setting. |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1569 nargin--; |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1570 } |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1571 } |
7202 | 1572 |
28271
5e1f4060289a
Make 1-input form "warning (STATE)" use special ID "all" (bug #58296).
Rik <rik@octave.org>
parents:
28268
diff
changeset
|
1573 if ((nargin == 1 |
5e1f4060289a
Make 1-input form "warning (STATE)" use special ID "all" (bug #58296).
Rik <rik@octave.org>
parents:
28268
diff
changeset
|
1574 && (arg1 == "on" || arg1 == "off" || arg1 == "error")) |
5e1f4060289a
Make 1-input form "warning (STATE)" use special ID "all" (bug #58296).
Rik <rik@octave.org>
parents:
28268
diff
changeset
|
1575 || (nargin >= 2 && arg2_lc == "all")) |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1576 { |
28271
5e1f4060289a
Make 1-input form "warning (STATE)" use special ID "all" (bug #58296).
Rik <rik@octave.org>
parents:
28268
diff
changeset
|
1577 // If "all" is given implicitly or explicitly as ID. |
5e1f4060289a
Make 1-input form "warning (STATE)" use special ID "all" (bug #58296).
Rik <rik@octave.org>
parents:
28268
diff
changeset
|
1578 if (arg1 == "error") |
28752
810eb29fc227
maint: Use C++ raw string literals to simplify backlsashing.
Rik <rik@octave.org>
parents:
28280
diff
changeset
|
1579 error (R"(warning: cannot specify "all" warning ID with state "error")"); |
7202 | 1580 |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1581 octave_map tmp; |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1582 |
28271
5e1f4060289a
Make 1-input form "warning (STATE)" use special ID "all" (bug #58296).
Rik <rik@octave.org>
parents:
28268
diff
changeset
|
1583 Cell id (1, 1); |
5e1f4060289a
Make 1-input form "warning (STATE)" use special ID "all" (bug #58296).
Rik <rik@octave.org>
parents:
28268
diff
changeset
|
1584 Cell st (1, 1); |
7206 | 1585 |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1586 id(0) = "all"; |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1587 st(0) = arg1; |
7206 | 1588 |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1589 tmp.assign ("identifier", id); |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1590 tmp.assign ("state", st); |
5582 | 1591 |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1592 es.warning_options (tmp); |
5567 | 1593 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1594 done = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1595 } |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1596 else if (arg2_lc == "backtrace") |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1597 { |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1598 if (arg1 != "error") |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1599 { |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1600 es.backtrace_on_warning (arg1 == "on"); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1601 done = true; |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1602 } |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1603 } |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1604 else if (arg2_lc == "debug") |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1605 { |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1606 if (arg1 != "error") |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1607 { |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1608 es.debug_on_warning (arg1 == "on"); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1609 done = true; |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1610 } |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1611 } |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1612 else if (arg2_lc == "verbose") |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1613 { |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1614 if (arg1 != "error") |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1615 { |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1616 es.verbose_warning (arg1 == "on"); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1617 done = true; |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1618 } |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1619 } |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1620 else if (arg2_lc == "quiet") |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1621 { |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1622 if (arg1 != "error") |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1623 { |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1624 es.quiet_warning (arg1 == "on"); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1625 done = true; |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1626 } |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1627 } |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1628 else |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1629 { |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1630 if (arg2_lc == "last") |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1631 arg2 = es.last_warning_id (); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1632 |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
1633 es.set_warning_option (arg1, arg2); |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1634 |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1635 done = true; |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1636 } |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1637 |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1638 if (done && nargout > 0) |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1639 retval = old_warning_options; |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1640 } |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1641 else if (arg1 == "query") |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1642 { |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1643 if (arg2_lc == "all") |
28268
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1644 { |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1645 if (nargout > 0) |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1646 retval = es.warning_options (); |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1647 else |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1648 es.display_warning_options (octave_stdout); |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1649 } |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1650 else if (arg2_lc == "backtrace" || arg2_lc == "debug" |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1651 || arg2_lc == "verbose" || arg2_lc == "quiet") |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1652 { |
28268
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1653 if (nargout > 0) |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1654 { |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1655 octave_scalar_map tmp; |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1656 tmp.assign ("identifier", arg2_lc); |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1657 if (arg2_lc == "backtrace") |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1658 tmp.assign ("state", es.backtrace_on_warning () ? "on" : "off"); |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1659 else if (arg2_lc == "debug") |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1660 tmp.assign ("state", es.debug_on_warning () ? "on" : "off"); |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1661 else if (arg2_lc == "verbose") |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1662 tmp.assign ("state", es.verbose_warning () ? "on" : "off"); |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1663 else |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1664 tmp.assign ("state", es.quiet_warning () ? "on" : "off"); |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1665 |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1666 retval = tmp; |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1667 } |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1668 else |
28268
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1669 { |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1670 if (arg2_lc == "backtrace") |
28752
810eb29fc227
maint: Use C++ raw string literals to simplify backlsashing.
Rik <rik@octave.org>
parents:
28280
diff
changeset
|
1671 octave_stdout << R"("backtrace" warning state is ")" << |
28268
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1672 (es.backtrace_on_warning () ? "on" : "off") << |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1673 "\"\n"; |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1674 else if (arg2_lc == "debug") |
28752
810eb29fc227
maint: Use C++ raw string literals to simplify backlsashing.
Rik <rik@octave.org>
parents:
28280
diff
changeset
|
1675 octave_stdout << R"("debug" warning state is ")" << |
28268
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1676 (es.debug_on_warning () ? "on" : "off") << |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1677 "\"\n"; |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1678 else if (arg2_lc == "verbose") |
28752
810eb29fc227
maint: Use C++ raw string literals to simplify backlsashing.
Rik <rik@octave.org>
parents:
28280
diff
changeset
|
1679 octave_stdout << R"("verbose" warning state is ")" << |
28268
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1680 (es.verbose_warning () ? "on" : "off") << |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1681 "\"\n"; |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1682 else |
28752
810eb29fc227
maint: Use C++ raw string literals to simplify backlsashing.
Rik <rik@octave.org>
parents:
28280
diff
changeset
|
1683 octave_stdout << R"("quiet" warning state is ")" << |
28268
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1684 (es.quiet_warning () ? "on" : "off") << |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1685 "\"\n"; |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1686 } |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1687 } |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1688 else |
28268
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1689 { |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1690 if (nargout > 0) |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1691 retval = es.warning_query (arg2); |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1692 else |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1693 { |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1694 octave_scalar_map tmp = es.warning_query (arg2); |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1695 |
28752
810eb29fc227
maint: Use C++ raw string literals to simplify backlsashing.
Rik <rik@octave.org>
parents:
28280
diff
changeset
|
1696 octave_stdout << '"' << arg2 << R"(" warning state is ")" << |
28268
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1697 tmp.getfield ("state").string_value () << |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1698 "\"\n"; |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1699 } |
7eddf9608d61
Pretty print warning() output state when nargout==0 (bug #58296).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
1700 } |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1701 |
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1702 done = true; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1703 } |
3934 | 1704 } |
20897
9aad16a799c9
maint: Replace argc variable name with nargin in C++ code.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1705 else if (nargin == 0) |
5567 | 1706 { |
19439
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
19421
diff
changeset
|
1707 if (nargout > 0) |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1708 retval = es.warning_options (); |
19439
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
19421
diff
changeset
|
1709 else |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
1710 es.display_warning_options (octave_stdout); |
3934 | 1711 |
5567 | 1712 done = true; |
1713 } | |
20897
9aad16a799c9
maint: Replace argc variable name with nargin in C++ code.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1714 else if (nargin == 1) |
5567 | 1715 { |
1716 octave_value arg = args(0); | |
1717 | |
24047
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1718 octave_map old_warning_options; |
5567 | 1719 |
23584
7ed6b258db91
maint: Deprecate is_map and replace with isstruct.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
1720 if (arg.isstruct ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1721 { |
11058
3329616444f0
replace Octave_map in debug.cc and error.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
11029
diff
changeset
|
1722 octave_map m = arg.map_value (); |
5567 | 1723 |
20897
9aad16a799c9
maint: Replace argc variable name with nargin in C++ code.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1724 if (! m.contains ("identifier") || ! m.contains ("state")) |
9aad16a799c9
maint: Replace argc variable name with nargin in C++ code.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1725 error ("warning: STATE structure must have fields 'identifier' and 'state'"); |
19439
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
19421
diff
changeset
|
1726 |
20897
9aad16a799c9
maint: Replace argc variable name with nargin in C++ code.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1727 // Simply step through the struct elements one at a time. |
19439
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
19421
diff
changeset
|
1728 |
20897
9aad16a799c9
maint: Replace argc variable name with nargin in C++ code.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1729 Cell ident = m.contents ("identifier"); |
9aad16a799c9
maint: Replace argc variable name with nargin in C++ code.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1730 Cell state = m.contents ("state"); |
19439
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
19421
diff
changeset
|
1731 |
20897
9aad16a799c9
maint: Replace argc variable name with nargin in C++ code.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1732 octave_idx_type nel = ident.numel (); |
19439
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
19421
diff
changeset
|
1733 |
24047
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1734 // Prepare output structure |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1735 old_warning_options = octave_map (m); |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1736 Cell oldstate (state); |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1737 |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1738 for (octave_idx_type i = 0; i < nel; i++) |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1739 { |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1740 std::string tid = ident(i).string_value (); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
1741 oldstate(i) = es.warning_query (tid).getfield ("state"); |
24047
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1742 } |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1743 old_warning_options.setfield ("state", oldstate); |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1744 |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1745 // Set new values |
20897
9aad16a799c9
maint: Replace argc variable name with nargin in C++ code.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1746 for (octave_idx_type i = 0; i < nel; i++) |
9aad16a799c9
maint: Replace argc variable name with nargin in C++ code.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1747 { |
9aad16a799c9
maint: Replace argc variable name with nargin in C++ code.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1748 std::string tst = state(i).string_value (); |
9aad16a799c9
maint: Replace argc variable name with nargin in C++ code.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
1749 std::string tid = ident(i).string_value (); |
19439
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
19421
diff
changeset
|
1750 |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
1751 es.set_warning_option (tst, tid); |
19439
93fbdbcb3349
fix handling of options struct passed to warning function (bug #36393)
John W. Eaton <jwe@octave.org>
parents:
19421
diff
changeset
|
1752 } |
5567 | 1753 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1754 done = true; |
5567 | 1755 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1756 if (nargout > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1757 retval = old_warning_options; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1758 } |
5567 | 1759 } |
1760 | |
20678
4b00afb5e9c3
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20666
diff
changeset
|
1761 if (! done) |
3935 | 1762 { |
5567 | 1763 octave_value_list nargs = args; |
1764 | |
1765 std::string id; | |
1766 | |
14558
0c9c85e702ca
better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents:
14361
diff
changeset
|
1767 bool have_fmt = maybe_extract_message_id ("warning", args, nargs, id); |
5567 | 1768 |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1769 std::string prev_msg = es.last_warning_message (); |
3935 | 1770 |
5567 | 1771 std::string curr_msg = handle_message (warning_with_id, id.c_str (), |
14558
0c9c85e702ca
better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents:
14361
diff
changeset
|
1772 "unspecified warning", nargs, |
0c9c85e702ca
better compatibility for error/warning message IDs and format specifiers
John W. Eaton <jwe@octave.org>
parents:
14361
diff
changeset
|
1773 have_fmt); |
3935 | 1774 |
1775 if (nargout > 0) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1776 retval = prev_msg; |
3935 | 1777 } |
1778 | |
3934 | 1779 return retval; |
1780 } | |
1781 | |
20963
6ed7bae8017b
Fix behavior of warning ("error") call (bug #45753).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20181
diff
changeset
|
1782 /* |
6ed7bae8017b
Fix behavior of warning ("error") call (bug #45753).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20181
diff
changeset
|
1783 |
24047
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1784 %!test <*51997> |
26596
cc0d942d0e20
Remove inconsistent warning "Octave:divide-by-zero" (bug #46650).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26376
diff
changeset
|
1785 %! id = "Octave:logical-conversion"; |
24047
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1786 %! current = warning ("query", id); |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1787 %! current_all = warning (); |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1788 %! previous = warning (current_all); |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1789 %! assert (previous, current_all); |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1790 %! previous = warning (current); |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1791 %! assert (previous, current); |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1792 %! previous = warning (current.state, id); |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1793 %! assert (previous, current); |
27746
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1794 |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1795 %!test <*57290> |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1796 %! warning ("oN", "Octave:test-57290-ID"); |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1797 %! warnst = warning ("QUery", "Octave:test-57290-ID"); |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1798 %! assert (warnst.state, "on"); |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1799 %! assert (warnst.identifier, "Octave:test-57290-ID"); |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1800 %! warning ("OFF", "Octave:test-57290-ID"); |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1801 %! warnst = warning ("QUery", "ALL"); |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1802 %! idx = strcmp ({warnst.identifier}, "Octave:test-57290-ID"); |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1803 %! assert (warnst(idx).state, "off"); |
ae821ac9ec74
Change warning to be case insensitive about options (bug #57290).
Rik <rik@octave.org>
parents:
27472
diff
changeset
|
1804 |
28271
5e1f4060289a
Make 1-input form "warning (STATE)" use special ID "all" (bug #58296).
Rik <rik@octave.org>
parents:
28268
diff
changeset
|
1805 %!error <cannot specify "all" warning ID> warning ("error") |
5e1f4060289a
Make 1-input form "warning (STATE)" use special ID "all" (bug #58296).
Rik <rik@octave.org>
parents:
28268
diff
changeset
|
1806 |
24047
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1807 */ |
9c198d1c84cd
Overhaul documentation for "warning" and fix output size (bug #51997).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
23850
diff
changeset
|
1808 |
10605
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10405
diff
changeset
|
1809 octave_value_list |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10405
diff
changeset
|
1810 set_warning_state (const std::string& id, const std::string& state) |
5794 | 1811 { |
1812 octave_value_list args; | |
1813 | |
1814 args(1) = id; | |
10605
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10405
diff
changeset
|
1815 args(0) = state; |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10405
diff
changeset
|
1816 |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30896
diff
changeset
|
1817 interpreter& interp = __get_interpreter__ (); |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23465
diff
changeset
|
1818 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1819 return Fwarning (interp, args, 1); |
10605
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10405
diff
changeset
|
1820 } |
5794 | 1821 |
10605
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10405
diff
changeset
|
1822 octave_value_list |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10405
diff
changeset
|
1823 set_warning_state (const octave_value_list& args) |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10405
diff
changeset
|
1824 { |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30896
diff
changeset
|
1825 interpreter& interp = __get_interpreter__ (); |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23465
diff
changeset
|
1826 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1827 return Fwarning (interp, args, 1); |
10605
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10405
diff
changeset
|
1828 } |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10405
diff
changeset
|
1829 |
29956
a956ca6698d2
move some error handling functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29951
diff
changeset
|
1830 int |
a956ca6698d2
move some error handling functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29951
diff
changeset
|
1831 warning_enabled (const std::string& id) |
a956ca6698d2
move some error handling functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29951
diff
changeset
|
1832 { |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30896
diff
changeset
|
1833 error_system& es = __get_error_system__ (); |
29956
a956ca6698d2
move some error handling functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29951
diff
changeset
|
1834 |
a956ca6698d2
move some error handling functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29951
diff
changeset
|
1835 return es.warning_enabled (id); |
a956ca6698d2
move some error handling functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29951
diff
changeset
|
1836 } |
a956ca6698d2
move some error handling functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29951
diff
changeset
|
1837 |
10605
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10405
diff
changeset
|
1838 void |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10405
diff
changeset
|
1839 disable_warning (const std::string& id) |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10405
diff
changeset
|
1840 { |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30896
diff
changeset
|
1841 error_system& es = __get_error_system__ (); |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
1842 |
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
1843 es.disable_warning (id); |
5794 | 1844 } |
1845 | |
23553
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23465
diff
changeset
|
1846 DEFMETHOD (lasterror, interp, args, , |
14723784b9f2
don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents:
23465
diff
changeset
|
1847 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1848 @deftypefn {} {@var{lasterr} =} lasterror () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1849 @deftypefnx {} {} lasterror (@var{err}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1850 @deftypefnx {} {} lasterror ("reset") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1851 Query or set the last error message structure. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1852 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1853 When called without arguments, return a structure containing the last error |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1854 message and other information related to this error. The elements of the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1855 structure are: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1856 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1857 @table @code |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1858 @item message |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1859 The text of the last error message |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1860 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1861 @item identifier |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1862 The message identifier of this error message |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1863 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1864 @item stack |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1865 A structure containing information on where the message occurred. This may |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1866 be an empty structure if the information cannot be obtained. The fields of |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1867 the structure are: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1868 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1869 @table @code |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1870 @item file |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1871 The name of the file where the error occurred |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1872 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1873 @item name |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1874 The name of function in which the error occurred |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1875 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1876 @item line |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1877 The line number at which the error occurred |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1878 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1879 @item column |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1880 An optional field with the column number at which the error occurred |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1881 @end table |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1882 @end table |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1883 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1884 The last error structure may be set by passing a scalar structure, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1885 @var{err}, as input. Any fields of @var{err} that match those above are |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1886 set while any unspecified fields are initialized with default values. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1887 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1888 If @code{lasterror} is called with the argument @qcode{"reset"}, all |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1889 fields are set to their default values. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1890 @seealso{lasterr, error, lastwarn} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
1891 @end deftypefn */) |
6361 | 1892 { |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14559
diff
changeset
|
1893 int nargin = args.length (); |
6361 | 1894 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1895 if (nargin > 1) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1896 print_usage (); |
6361 | 1897 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1898 error_system& es = interp.get_error_system (); |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1899 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1900 octave_scalar_map err; |
6361 | 1901 |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1902 err.assign ("message", es.last_error_message ()); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1903 err.assign ("identifier", es.last_error_id ()); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1904 |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1905 err.assign ("stack", octave_value (es.last_error_stack ())); |
7976
736124a4fa3d
lasterr, lasterror: unwind-protect error_state
John W. Eaton <jwe@octave.org>
parents:
7882
diff
changeset
|
1906 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1907 if (nargin == 1) |
6361 | 1908 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
1909 tree_evaluator& tw = interp.get_evaluator (); |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1910 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1911 if (args(0).is_string ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1912 { |
20980
81c2b14c209f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20946
diff
changeset
|
1913 if (args(0).string_value () != "reset") |
81c2b14c209f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20946
diff
changeset
|
1914 error ("lasterror: unrecognized string argument"); |
6361 | 1915 |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1916 es.last_error_message (""); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1917 es.last_error_id (""); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1918 |
27199
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27161
diff
changeset
|
1919 es.last_error_stack (tw.empty_backtrace ()); |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1920 } |
23584
7ed6b258db91
maint: Deprecate is_map and replace with isstruct.
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
1921 else if (args(0).isstruct ()) |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1922 { |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1923 octave_scalar_map new_err = args(0).scalar_map_value (); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1924 octave_scalar_map new_err_stack; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1925 std::string new_error_message; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1926 std::string new_error_id; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1927 std::string new_error_file; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1928 std::string new_error_name; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1929 int new_error_line = -1; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1930 int new_error_column = -1; |
21856
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
1931 bool initialize_stack = false; |
6361 | 1932 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1933 if (new_err.contains ("message")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1934 { |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
1935 const std::string tmp |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
1936 = new_err.getfield ("message").string_value (); |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1937 new_error_message = tmp; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1938 } |
6361 | 1939 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1940 if (new_err.contains ("identifier")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1941 { |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
1942 const std::string tmp |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
1943 = new_err.getfield ("identifier").string_value (); |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1944 new_error_id = tmp; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1945 } |
6361 | 1946 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1947 if (new_err.contains ("stack")) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1948 { |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23573
diff
changeset
|
1949 if (new_err.getfield ("stack").isempty ()) |
21856
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
1950 initialize_stack = true; |
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
1951 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1952 { |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
1953 new_err_stack |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
1954 = new_err.getfield ("stack").scalar_map_value (); |
21856
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
1955 |
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
1956 if (new_err_stack.contains ("file")) |
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
1957 { |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
1958 const std::string tmp |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
1959 = new_err_stack.getfield ("file").string_value (); |
21856
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
1960 new_error_file = tmp; |
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
1961 } |
6361 | 1962 |
21856
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
1963 if (new_err_stack.contains ("name")) |
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
1964 { |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
1965 const std::string tmp |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
1966 = new_err_stack.getfield ("name").string_value (); |
21856
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
1967 new_error_name = tmp; |
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
1968 } |
6361 | 1969 |
21856
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
1970 if (new_err_stack.contains ("line")) |
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
1971 { |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
1972 const int tmp |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
1973 = new_err_stack.getfield ("line").nint_value (); |
21856
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
1974 new_error_line = tmp; |
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
1975 } |
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
1976 |
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
1977 if (new_err_stack.contains ("column")) |
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
1978 { |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
1979 const int tmp |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
27199
diff
changeset
|
1980 = new_err_stack.getfield ("column").nint_value (); |
21856
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
1981 new_error_column = tmp; |
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
1982 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1983 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
1984 } |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1985 |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1986 es.last_error_message (new_error_message); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1987 es.last_error_id (new_error_id); |
6361 | 1988 |
21856
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
1989 if (initialize_stack) |
27199
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27161
diff
changeset
|
1990 es.last_error_stack (tw.empty_backtrace ()); |
21856
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
1991 else if (new_err.contains ("stack")) |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1992 { |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1993 new_err_stack.setfield ("file", new_error_file); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1994 new_err_stack.setfield ("name", new_error_name); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1995 new_err_stack.setfield ("line", new_error_line); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1996 new_err_stack.setfield ("column", new_error_column); |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1997 |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
1998 es.last_error_stack (new_err_stack); |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
1999 } |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
2000 else |
27199
f27002104c5b
eliminate direct access to call_stack in error functions
John W. Eaton <jwe@octave.org>
parents:
27161
diff
changeset
|
2001 es.last_error_stack (tw.backtrace ()); |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
2002 } |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
2003 else |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
2004 error ("lasterror: argument must be a structure or a string"); |
6361 | 2005 } |
2006 | |
21127
df7891224709
maint: Use "return ovl (...)" in DEFUN macros.
Rik <rik@octave.org>
parents:
21121
diff
changeset
|
2007 return ovl (err); |
6361 | 2008 } |
2009 | |
21856
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
2010 /* |
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
2011 ## Test lasterror with empty error state |
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
2012 %!test |
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
2013 %! lasterror ("reset"); |
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
2014 %! x = lasterror (); |
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
2015 %! assert (x.identifier, "") |
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
2016 %! assert (x.message, "") |
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
2017 %! assert (isempty (x.stack)) |
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
2018 %! lasterror (x); |
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
2019 %! y = lasterror (); |
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
2020 %! assert (y, x); |
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
2021 */ |
c9c5340d4758
lasterror: Allow setting error state with an empty stack
Mike Miller <mtmiller@octave.org>
parents:
21751
diff
changeset
|
2022 |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2023 DEFMETHOD (lasterr, interp, args, nargout, |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2024 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2025 @deftypefn {} {[@var{msg}, @var{msgid}] =} lasterr () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2026 @deftypefnx {} {} lasterr (@var{msg}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2027 @deftypefnx {} {} lasterr (@var{msg}, @var{msgid}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2028 Query or set the last error message. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2029 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2030 When called without input arguments, return the last error message and |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2031 message identifier. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2032 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2033 With one argument, set the last error message to @var{msg}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2034 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2035 With two arguments, also set the last message identifier. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2036 @seealso{lasterror, error, lastwarn} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2037 @end deftypefn */) |
3935 | 2038 { |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20803
diff
changeset
|
2039 int nargin = args.length (); |
3935 | 2040 |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20803
diff
changeset
|
2041 if (nargin > 2) |
5823 | 2042 print_usage (); |
3935 | 2043 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
2044 error_system& es = interp.get_error_system (); |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2045 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
2046 string_vector argv = args.make_argv ("lasterr"); |
5567 | 2047 |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2048 std::string prev_error_id = es.last_error_id (); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2049 std::string prev_error_message = es.last_error_message (); |
5567 | 2050 |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20803
diff
changeset
|
2051 if (nargin == 2) |
20828
7883f240d8ea
Clear error/warning ID when lasterror/lastwarning called with just a message.
Rik <rik@octave.org>
parents:
20827
diff
changeset
|
2052 { |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2053 es.last_error_id (argv[2]); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2054 es.last_error_message (argv[1]); |
20828
7883f240d8ea
Clear error/warning ID when lasterror/lastwarning called with just a message.
Rik <rik@octave.org>
parents:
20827
diff
changeset
|
2055 } |
7883f240d8ea
Clear error/warning ID when lasterror/lastwarning called with just a message.
Rik <rik@octave.org>
parents:
20827
diff
changeset
|
2056 else if (nargin == 1) |
7883f240d8ea
Clear error/warning ID when lasterror/lastwarning called with just a message.
Rik <rik@octave.org>
parents:
20827
diff
changeset
|
2057 { |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2058 es.last_error_id (""); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2059 es.last_error_message (argv[1]); |
20828
7883f240d8ea
Clear error/warning ID when lasterror/lastwarning called with just a message.
Rik <rik@octave.org>
parents:
20827
diff
changeset
|
2060 } |
5567 | 2061 |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20803
diff
changeset
|
2062 if (nargin == 0 || nargout > 0) |
20828
7883f240d8ea
Clear error/warning ID when lasterror/lastwarning called with just a message.
Rik <rik@octave.org>
parents:
20827
diff
changeset
|
2063 return ovl (prev_error_message, prev_error_id); |
7883f240d8ea
Clear error/warning ID when lasterror/lastwarning called with just a message.
Rik <rik@octave.org>
parents:
20827
diff
changeset
|
2064 else |
20941
a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
2065 return ovl (); |
3935 | 2066 } |
2067 | |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2068 DEFMETHOD (lastwarn, interp, args, nargout, |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2069 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2070 @deftypefn {} {[@var{msg}, @var{msgid}] =} lastwarn () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2071 @deftypefnx {} {} lastwarn (@var{msg}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2072 @deftypefnx {} {} lastwarn (@var{msg}, @var{msgid}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2073 Query or set the last warning message. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2074 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2075 When called without input arguments, return the last warning message and |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2076 message identifier. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2077 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2078 With one argument, set the last warning message to @var{msg}. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2079 |
30888
32d2b6604a9f
doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents:
30723
diff
changeset
|
2080 With two arguments, also set the last message identifier to @var{msgid}. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2081 @seealso{warning, lasterror, lasterr} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2082 @end deftypefn */) |
3934 | 2083 { |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20803
diff
changeset
|
2084 int nargin = args.length (); |
5567 | 2085 |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20803
diff
changeset
|
2086 if (nargin > 2) |
5823 | 2087 print_usage (); |
3934 | 2088 |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
2089 error_system& es = interp.get_error_system (); |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2090 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20785
diff
changeset
|
2091 string_vector argv = args.make_argv ("lastwarn"); |
5567 | 2092 |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2093 std::string prev_warning_id = es.last_warning_id (); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2094 std::string prev_warning_message = es.last_warning_message (); |
3934 | 2095 |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20803
diff
changeset
|
2096 if (nargin == 2) |
20828
7883f240d8ea
Clear error/warning ID when lasterror/lastwarning called with just a message.
Rik <rik@octave.org>
parents:
20827
diff
changeset
|
2097 { |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2098 es.last_warning_id (argv[2]); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2099 es.last_warning_message (argv[1]); |
20828
7883f240d8ea
Clear error/warning ID when lasterror/lastwarning called with just a message.
Rik <rik@octave.org>
parents:
20827
diff
changeset
|
2100 } |
7883f240d8ea
Clear error/warning ID when lasterror/lastwarning called with just a message.
Rik <rik@octave.org>
parents:
20827
diff
changeset
|
2101 else if (nargin == 1) |
7883f240d8ea
Clear error/warning ID when lasterror/lastwarning called with just a message.
Rik <rik@octave.org>
parents:
20827
diff
changeset
|
2102 { |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2103 es.last_warning_id (""); |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2104 es.last_warning_message (argv[1]); |
20828
7883f240d8ea
Clear error/warning ID when lasterror/lastwarning called with just a message.
Rik <rik@octave.org>
parents:
20827
diff
changeset
|
2105 } |
5567 | 2106 |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20803
diff
changeset
|
2107 if (nargin == 0 || nargout > 0) |
20828
7883f240d8ea
Clear error/warning ID when lasterror/lastwarning called with just a message.
Rik <rik@octave.org>
parents:
20827
diff
changeset
|
2108 return ovl (prev_warning_message, prev_warning_id); |
7883f240d8ea
Clear error/warning ID when lasterror/lastwarning called with just a message.
Rik <rik@octave.org>
parents:
20827
diff
changeset
|
2109 else |
20941
a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
2110 return ovl (); |
897 | 2111 } |
2112 | |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2113 DEFMETHOD (beep_on_error, interp, args, nargout, |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2114 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2115 @deftypefn {} {@var{val} =} beep_on_error () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2116 @deftypefnx {} {@var{old_val} =} beep_on_error (@var{new_val}) |
30588
ed17822e7662
doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
2117 @deftypefnx {} {@var{old_val} =} beep_on_error (@var{new_val}, "local") |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2118 Query or set the internal variable that controls whether Octave will try |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2119 to ring the terminal bell before printing an error message. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2120 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2121 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2122 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2123 The original variable value is restored when exiting the function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2124 @end deftypefn */) |
3707 | 2125 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
2126 error_system& es = interp.get_error_system (); |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2127 |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2128 return es.beep_on_error (args, nargout); |
3707 | 2129 } |
2130 | |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2131 DEFMETHOD (debug_on_error, interp, args, nargout, |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2132 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2133 @deftypefn {} {@var{val} =} debug_on_error () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2134 @deftypefnx {} {@var{old_val} =} debug_on_error (@var{new_val}) |
30588
ed17822e7662
doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
2135 @deftypefnx {} {@var{old_val} =} debug_on_error (@var{new_val}, "local") |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2136 Query or set the internal variable that controls whether Octave will try |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2137 to enter the debugger when an error is encountered. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2138 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2139 This will also inhibit printing of the normal traceback message (you will |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2140 only see the top-level error message). |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2141 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2142 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2143 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2144 The original variable value is restored when exiting the function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2145 @seealso{debug_on_warning, debug_on_interrupt} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2146 @end deftypefn */) |
5794 | 2147 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
2148 error_system& es = interp.get_error_system (); |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2149 |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2150 return es.debug_on_error (args, nargout); |
5794 | 2151 } |
3707 | 2152 |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2153 DEFMETHOD (debug_on_warning, interp, args, nargout, |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2154 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2155 @deftypefn {} {@var{val} =} debug_on_warning () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2156 @deftypefnx {} {@var{old_val} =} debug_on_warning (@var{new_val}) |
30588
ed17822e7662
doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents:
30565
diff
changeset
|
2157 @deftypefnx {} {@var{old_val} =} debug_on_warning (@var{new_val}, "local") |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2158 Query or set the internal variable that controls whether Octave will try |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2159 to enter the debugger when a warning is encountered. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2160 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2161 When called from inside a function with the @qcode{"local"} option, the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2162 variable is changed locally for the function and any subroutines it calls. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2163 The original variable value is restored when exiting the function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2164 @seealso{debug_on_error, debug_on_interrupt} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21885
diff
changeset
|
2165 @end deftypefn */) |
5794 | 2166 { |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
2167 error_system& es = interp.get_error_system (); |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2168 |
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2169 return es.debug_on_warning (args, nargout); |
2174 | 2170 } |
2171 | |
11029
4ab04ea74b08
make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents:
10840
diff
changeset
|
2172 void |
29961
7d6709900da7
eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents:
29960
diff
changeset
|
2173 interpreter_try (unwind_protect& frame) |
11029
4ab04ea74b08
make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents:
10840
diff
changeset
|
2174 { |
31105
670a0d878af1
eliminate WHO arguments from interpreter-private functions
John W. Eaton <jwe@octave.org>
parents:
30896
diff
changeset
|
2175 error_system& es = __get_error_system__ (); |
27160
6b0c61a5a0f0
move global error configuration and status variables inside a class
John W. Eaton <jwe@octave.org>
parents:
27037
diff
changeset
|
2176 |
27471 | 2177 es.interpreter_try (frame); |
11029
4ab04ea74b08
make an internal function for try simulation
Jaroslav Hajek <highegg@gmail.com>
parents:
10840
diff
changeset
|
2178 } |
27161
7883e6e71b0a
additional refactoring of error handling functions
John W. Eaton <jwe@octave.org>
parents:
27160
diff
changeset
|
2179 |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
31577
diff
changeset
|
2180 OCTAVE_END_NAMESPACE(octave) |