#ifndef morpheo_ErrorMorpheo #define morpheo_ErrorMorpheo /* * $Id: ErrorMorpheo.h 82 2008-05-01 16:48:45Z rosiere $ * * [ Description ] * */ #include "ToString.h" #include #include namespace morpheo { #define ERRORMORPHEO(funcname,msg) ErrorMorpheo(funcname,msg,__LINE__,__FILE__) class ErrorMorpheo : public std::exception { // -----[ fields ]---------------------------------------------------- private : std::string _msg; // -----[ methods ]--------------------------------------------------- public : ErrorMorpheo () throw() {_msg="Exception detected ...";} public : ErrorMorpheo (std::string msg) throw() {_msg=msg;} public : ErrorMorpheo (std::string funcname, std::string msg , int line , std::string file ) throw() { _msg = toString("<%s> at line %d, in file %s : %s",funcname.c_str(),line,file.c_str(),msg.c_str()); } public : ~ErrorMorpheo (void) throw() {} public : const char* what () const throw() { return ( _msg.c_str() );} }; class TestMorpheo : public std::exception { // -----[ fields ]---------------------------------------------------- private : std::string _msg; // -----[ methods ]--------------------------------------------------- public : TestMorpheo () throw() {_msg="Test error ...";} public : TestMorpheo (std::string msg) throw() {_msg=msg;} public : ~TestMorpheo (void) throw() {} public : const char* what () const throw() { return ( _msg.c_str() );} }; }; // end namespace morpheo #endif