diff src/ov-usr-fcn.cc @ 8011:3100283874d7

improve backtrace error messages
author John W. Eaton <jwe@octave.org>
date Tue, 05 Aug 2008 23:09:32 -0400
parents 0d607e8dbbfa
children b3e667f1ab4c
line wrap: on
line diff
--- a/src/ov-usr-fcn.cc	Tue Aug 05 12:14:33 2008 -0400
+++ b/src/ov-usr-fcn.cc	Tue Aug 05 23:09:32 2008 -0400
@@ -110,14 +110,14 @@
 {
   octave_value_list retval;
 
+  unwind_protect::begin_frame ("user_script_eval");
+
   if (! error_state)
     {
       if (args.length () == 0 && nargout == 0)
 	{
 	  if (cmd_list)
 	    {
-	      unwind_protect::begin_frame ("user_script_eval");
-
 	      unwind_protect_int (call_depth);
 	      call_depth++;
 
@@ -134,20 +134,17 @@
 
 		  if (tree_break_command::breaking)
 		    tree_break_command::breaking--;
-
-		  if (error_state)
-		    traceback_error ();
 		}
 	      else
 		::error ("max_recursion_limit exceeded");
-
-	      unwind_protect::run_frame ("user_script_eval");
     	    }
 	}
       else
 	error ("invalid call to script");
     }
 
+  unwind_protect::run_frame ("user_script_eval");
+
   return retval;
 }
 
@@ -157,32 +154,6 @@
   tw.visit_octave_user_script (*this);
 }
 
-// FIXME -- this function is exactly the same as
-// octave_user_function::traceback_error.
-
-void
-octave_user_script::traceback_error (void) const
-{
-  if (error_state >= 0)
-    error_state = -1;
-
-  if (my_name.empty ())
-    {
-      if (file_name.empty ())
-	::error ("called from `?unknown?'");
-      else
-	::error ("called from file `%s'", file_name.c_str ());
-    }
-  else
-    {
-      if (file_name.empty ())
-	::error ("called from `%s'", my_name.c_str ());
-      else 
-	::error ("called from `%s' in file `%s'",
-		 my_name.c_str (), file_name.c_str ());
-    }
-}
-
 // User defined functions.
 
 DEFINE_OCTAVE_ALLOCATOR (octave_user_function);
@@ -473,10 +444,7 @@
       tree_break_command::breaking--;
 
     if (error_state)
-      {
-	traceback_error ();
-	goto abort;
-      }
+      goto abort;
     
     // Copy return values out.
 
@@ -511,29 +479,6 @@
 }
 
 void
-octave_user_function::traceback_error (void) const
-{
-  if (error_state >= 0)
-    error_state = -1;
-
-  if (my_name.empty ())
-    {
-      if (file_name.empty ())
-	::error ("called from `?unknown?'");
-      else
-	::error ("called from file `%s'", file_name.c_str ());
-    }
-  else
-    {
-      if (file_name.empty ())
-	::error ("called from `%s'", my_name.c_str ());
-      else 
-	::error ("called from `%s' in file `%s'",
-		 my_name.c_str (), file_name.c_str ());
-    }
-}
-
-void
 octave_user_function::accept (tree_walker& tw)
 {
   tw.visit_octave_user_function (*this);