#ifndef Morpheo_ErrorMorpheo_h #define Morpheo_ErrorMorpheo_h /* * $Id: ErrorMorpheo.h 146 2011-02-01 20:57:54Z rosiere $ * * [ Description ] * */ #include "Common/include/ToString.h" #include "Common/include/Translation.h" #include "Common/include/Message.h" #include #include namespace morpheo { #define ERRORMORPHEO(funcname,msg) \ ErrorMorpheo(funcname,msg,__LINE__,__FILE__) #define THROW_ERRORMORPHEO(cond,funcname,msg) \ do \ { \ if (cond) \ { \ throw ERRORMORPHEO(funcname,msg); \ } \ } \ while (0) class ErrorMorpheo : public std::exception { // -----[ fields ]---------------------------------------------------- private : std::string _msg; // -----[ methods ]--------------------------------------------------- public : ErrorMorpheo () throw() {_msg = toString("%s ",MSG_ERROR); _msg+="Exception detected ...";} public : ErrorMorpheo (std::string msg) throw() {_msg = toString("%s ",MSG_ERROR); _msg+=msg;} public : ErrorMorpheo (std::string funcname, std::string msg , int line , std::string file ) throw() { #ifdef DEBUG _msg = toString(_("%s at line %d, in file %s"),MSG_ERROR,line,file.c_str()); _msg = toString(_("%s <%s> %s"),MSG_ERROR,funcname.c_str(),msg.c_str()); #else _msg = toString(_("%s %s"),MSG_ERROR,msg.c_str()); #endif // msg("%s",_msg.c_str()); } public : ~ErrorMorpheo (void) throw() {} public : const char* what () const throw() { return ( _msg.c_str() );} }; }; // end namespace morpheo #endif