]> Creatis software - bbtk.git/commitdiff
Fixed the systematic '* LINE : 0' bug when error in script
authorguigues <guigues>
Wed, 26 Nov 2008 12:36:42 +0000 (12:36 +0000)
committerguigues <guigues>
Wed, 26 Nov 2008 12:36:42 +0000 (12:36 +0000)
kernel/src/bbtkInterpreter.cxx
kernel/src/bbtkInterpreter.h

index d112f73bdb4f4c19c065bde7e511962c235c2caa..4b2e86615be05108e85c3ef3b810670b3252edb8 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkInterpreter.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/10/17 08:18:13 $
-  Version:   $Revision: 1.77 $
+  Date:      $Date: 2008/11/26 12:36:42 $
+  Version:   $Revision: 1.78 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -396,6 +396,28 @@ namespace bbtk
       mScriptLine(script_line)
   {
   }
+  //=======================================================================
+  void Interpreter::CatchInterpreterException( const InterpreterError& e )
+  {
+    if (mThrow) 
+      {
+       CloseAllFiles();
+       throw InterpreterError(e);
+      }
+    else
+      {
+       std::stringstream mess;
+       mess << "* ERROR : "<<e.GetErrorMessage()<<std::endl;
+       if (e.IsInScriptFile())
+         {
+           mess << "* FILE  : \""<<e.GetScriptFile()<<"\""<<std::endl;
+           mess << "* LINE  : "<<e.GetScriptLine()<<std::endl;
+         }
+       std::cerr << mess.str();
+      }
+  }
+  //=======================================================================
+
   //=======================================================================
   void Interpreter::CatchBbtkException( const bbtk::Exception& e )
   {
@@ -496,6 +518,11 @@ namespace bbtk
       status = Interpreter_QUIT;               \
       if (mThrow) throw QuitException();       \
     }                                          \
+  catch (InterpreterError e)                   \
+    {                                          \
+      status = Interpreter_ERROR;              \
+      CatchInterpreterException(e);                    \
+    }                                          \
   catch (bbtk::Exception e)                    \
     {                                          \
       status = Interpreter_ERROR;              \
index 33c82aca87b4e2719e33bbd6d7703cf13f463a93..4b6669cf7ae00ee788e4f72158754dac4e67dcec 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkInterpreter.h,v $
   Language:  C++
-  Date:      $Date: 2008/10/17 08:18:13 $
-  Version:   $Revision: 1.35 $
+  Date:      $Date: 2008/11/26 12:36:43 $
+  Version:   $Revision: 1.36 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -293,6 +293,7 @@ namespace bbtk
                     std::string includeScriptName);
 
     /// 
+    void CatchInterpreterException( const InterpreterError& e );
     void CatchBbtkException( const bbtk::Exception& e );
     void CatchStdException( const std::exception& e );
     void CatchUnknownException();