changeset 30282:d55be375982e

improve debug_on_error behavior with assert (bug #55178) * assert.m: Set debug_on_error to false locally before emitting final error.
author John W. Eaton <jwe@octave.org>
date Fri, 12 Nov 2021 08:25:15 -0500
parents 4730becad0b1
children b7bce52e4500
files scripts/testfun/assert.m
diffstat 1 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/testfun/assert.m	Thu Nov 11 15:18:35 2021 -0500
+++ b/scripts/testfun/assert.m	Fri Nov 12 08:25:15 2021 -0500
@@ -93,6 +93,14 @@
     if (nargin == 1 || (nargin > 1 && islogical (cond) && ischar (varargin{1})))
       if ((! isnumeric (cond) && ! islogical (cond))
           || isempty (cond) || ! all (cond(:)))
+
+        ## We don't want to start the debugger here if debug_on_error is
+        ## true so we set it to false and make the change local.  Then
+        ## debug_on_error will be reset to true after this function
+        ## returns and the debugger will start at the location of the
+        ## call to print_usage.
+        debug_on_error (false, "local");
+
         if (nargin == 1)
           ## Perhaps, say which elements failed?
           argin = ["(" inputname(1, false) ")"];
@@ -466,6 +474,14 @@
   if (call_depth == -1)
     ## Last time through.  If there were any errors on any pass, raise a flag.
     if (! isempty (errmsg))
+
+      ## We don't want to start the debugger here if debug_on_error is
+      ## true so we set it to false and make the change local.  Then
+      ## debug_on_error will be reset to true after this function
+      ## returns and the debugger will start at the location of the call
+      ## to print_usage.
+      debug_on_error (false, "local");
+
       error (errmsg);
     endif
   endif