X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=kernel%2Fsrc%2FbbtkInterpreter.cxx;h=544729156a10cb88e6d430f6a174648a5194c666;hb=fc399c5aab38ad24ea5d57552701411b4d805181;hp=82edfcd775c46d173dc99d500d29f9d0492dfcf0;hpb=0bfd6ea8a50ca866039ce1eabdb8df2b3a0330b1;p=bbtk.git diff --git a/kernel/src/bbtkInterpreter.cxx b/kernel/src/bbtkInterpreter.cxx index 82edfcd..5447291 100644 --- a/kernel/src/bbtkInterpreter.cxx +++ b/kernel/src/bbtkInterpreter.cxx @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkInterpreter.cxx,v $ $ Language: C++ - Date: $Date: 2008/03/21 11:44:37 $ - Version: $Revision: 1.51 $ + Date: $Date: 2008/03/21 14:59:39 $ + Version: $Revision: 1.52 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -296,6 +296,143 @@ bufferNb =0; //======================================================================= + InterpreterError::InterpreterError( const std::string& message, + bool in_script_file, + const std::string& script_file, + int script_line + ) + : Exception("Interpreter",0,message), + mInScriptFile(in_script_file), + mScriptFile(script_file), + mScriptLine(script_line) + { + } + InterpreterError::InterpreterError( const Exception& excep, + bool in_script_file, + const std::string& script_file, + int script_line + ) + : Exception(excep), + mInScriptFile(in_script_file), + mScriptFile(script_file), + mScriptLine(script_line) + { + } + //======================================================================= + void Interpreter::CatchBbtkException( const bbtk::Exception& e ) + { + if (mThrow) + { + bool in_script = false; + std::string file(""); + int line = 0; + if (mFileName.size()) { + std::ifstream* fs = dynamic_cast(mFile.back()); + if (fs!=0) in_script = true; + file = mFileName.back(); + line = mLine.back(); + } + throw InterpreterError(e,in_script,file,line); + } + else + { + std::stringstream mess; + mess << "* ERROR : "<(mFile.back()); + if (fs!=0) in_script = true; + file = mFileName.back(); + line = mLine.back(); + } + throw InterpreterError(e.what(),in_script,file,line); + } + else + { + std::stringstream mess; + mess << "* ERROR : "<(mFile.back()); + if (fs!=0) in_script = true; + file = mFileName.back(); + line = mLine.back(); + } + throw InterpreterError("Unknown exception caught", + in_script,file,line); + } + else + { + std::stringstream mess; + mess << "* UNDEFINED ERROR (not a bbtk nor a std exception)" + << std::endl; + if (mFileName.size()) { + mess << "* FILE : \""<