changeset 19455:8b785ca93de7

don't print stack trace on errors if error_state is -2 * error.cc (error_2): Don't print stack trace on errors if error_state is -2.
author John W. Eaton <jwe@octave.org>
date Sun, 21 Dec 2014 19:50:40 -0500
parents 82f2a3437e02
children e23aedcc70a7
files libinterp/corefcn/error.cc
diffstat 1 files changed, 66 insertions(+), 65 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/error.cc	Sun Dec 21 21:00:51 2014 -0800
+++ b/libinterp/corefcn/error.cc	Sun Dec 21 19:50:40 2014 -0500
@@ -267,6 +267,70 @@
     }
 }
 
+static void
+pr_where_2 (const char *fmt, va_list args)
+{
+  if (fmt)
+    {
+      if (*fmt)
+        {
+          size_t len = strlen (fmt);
+
+          if (len > 0)
+            {
+              if (fmt[len - 1] == '\n')
+                {
+                  if (len > 1)
+                    {
+                      char *tmp_fmt = strsave (fmt);
+                      tmp_fmt[len - 1] = '\0';
+                      verror (false, std::cerr, 0, "", tmp_fmt, args);
+                      delete [] tmp_fmt;
+                    }
+                }
+              else
+                verror (false, std::cerr, 0, "", fmt, args);
+            }
+        }
+    }
+  else
+    panic ("pr_where_2: invalid format");
+}
+
+static void
+pr_where_1 (const char *fmt, ...)
+{
+  va_list args;
+  va_start (args, fmt);
+  pr_where_2 (fmt, args);
+  va_end (args);
+}
+
+static void
+pr_where (const char *who)
+{
+  std::list<octave_call_stack::stack_frame> frames
+    = octave_call_stack::backtrace_frames ();
+
+  size_t nframes = frames.size ();
+
+  if (nframes > 0)
+    pr_where_1 ("%s: called from\n", who);
+
+  for (std::list<octave_call_stack::stack_frame>::const_iterator p = frames.begin ();
+       p != frames.end (); p++)
+    {
+      const octave_call_stack::stack_frame& elt = *p;
+
+      std::string fcn_name = elt.fcn_name ();
+      int line = elt.line ();
+      int column = elt.column ();
+
+      pr_where_1 ("    %s at line %d column %d\n",
+                  fcn_name.c_str (), line, column);
+    }
+}
+
 // Note that we don't actually print any message if the error string
 // is just "" or "\n".  This allows error ("") and error ("\n") to
 // just set the error state.
@@ -381,77 +445,14 @@
 }
 
 static void
-pr_where_2 (const char *fmt, va_list args)
-{
-  if (fmt)
-    {
-      if (*fmt)
-        {
-          size_t len = strlen (fmt);
-
-          if (len > 0)
-            {
-              if (fmt[len - 1] == '\n')
-                {
-                  if (len > 1)
-                    {
-                      char *tmp_fmt = strsave (fmt);
-                      tmp_fmt[len - 1] = '\0';
-                      verror (false, std::cerr, 0, "", tmp_fmt, args);
-                      delete [] tmp_fmt;
-                    }
-                }
-              else
-                verror (false, std::cerr, 0, "", fmt, args);
-            }
-        }
-    }
-  else
-    panic ("pr_where_2: invalid format");
-}
-
-static void
-pr_where_1 (const char *fmt, ...)
-{
-  va_list args;
-  va_start (args, fmt);
-  pr_where_2 (fmt, args);
-  va_end (args);
-}
-
-static void
-pr_where (const char *who)
-{
-  std::list<octave_call_stack::stack_frame> frames
-    = octave_call_stack::backtrace_frames ();
-
-  size_t nframes = frames.size ();
-
-  if (nframes > 0)
-    pr_where_1 ("%s: called from\n", who);
-  
-  for (std::list<octave_call_stack::stack_frame>::const_iterator p = frames.begin ();
-       p != frames.end (); p++)
-    {
-      const octave_call_stack::stack_frame& elt = *p;
-
-      std::string fcn_name = elt.fcn_name ();
-      int line = elt.line ();
-      int column = elt.column ();
-
-      pr_where_1 ("    %s at line %d column %d\n",
-                  fcn_name.c_str (), line, column);
-    }
-}
-
-static void
 error_2 (const char *id, const char *fmt, va_list args, bool with_cfn = false)
 {
   int init_state = error_state;
 
   error_1 (std::cerr, "error", id, fmt, args, with_cfn);
 
-  if (! symbol_table::at_top_level () && ! discard_error_messages)
+  if (error_state != -2 && ! symbol_table::at_top_level ()
+      && ! discard_error_messages)
     pr_where ("error");
 
   if ((interactive || forced_interactive)