[2] | 1 | #ifndef morpheo_ErrorMorpheo |
---|
| 2 | #define morpheo_ErrorMorpheo |
---|
| 3 | |
---|
| 4 | /* |
---|
| 5 | * $Id$ |
---|
| 6 | * |
---|
[71] | 7 | * [ Description ] |
---|
[2] | 8 | * |
---|
| 9 | */ |
---|
| 10 | |
---|
[71] | 11 | #include "ToString.h" |
---|
[2] | 12 | #include <iostream> |
---|
| 13 | #include <exception> |
---|
| 14 | |
---|
| 15 | namespace morpheo { |
---|
| 16 | |
---|
[71] | 17 | #define ERRORMORPHEO(funcname,msg) ErrorMorpheo(funcname,msg,__LINE__,__FILE__) |
---|
| 18 | |
---|
| 19 | class ErrorMorpheo : public std::exception |
---|
[2] | 20 | { |
---|
| 21 | // -----[ fields ]---------------------------------------------------- |
---|
[71] | 22 | private : std::string _msg; |
---|
[2] | 23 | |
---|
| 24 | // -----[ methods ]--------------------------------------------------- |
---|
[71] | 25 | public : ErrorMorpheo () throw() {_msg="Exception detected ...";} |
---|
| 26 | public : ErrorMorpheo (std::string msg) throw() {_msg=msg;} |
---|
| 27 | public : ErrorMorpheo (std::string funcname, |
---|
| 28 | std::string msg , |
---|
| 29 | int line , |
---|
| 30 | std::string file ) throw() |
---|
| 31 | { |
---|
| 32 | _msg = "<"+funcname+"> at line " + toString(line) + ", in file " + file + " : "+msg; |
---|
| 33 | } |
---|
[2] | 34 | public : ~ErrorMorpheo (void) throw() {} |
---|
| 35 | public : const char* what () const throw() { return ( _msg.c_str() );} |
---|
| 36 | |
---|
| 37 | }; |
---|
| 38 | |
---|
[71] | 39 | class TestMorpheo : public std::exception |
---|
[3] | 40 | { |
---|
| 41 | // -----[ fields ]---------------------------------------------------- |
---|
[71] | 42 | private : std::string _msg; |
---|
[3] | 43 | |
---|
| 44 | // -----[ methods ]--------------------------------------------------- |
---|
[71] | 45 | public : TestMorpheo () throw() {_msg="Test error ...";} |
---|
| 46 | public : TestMorpheo (std::string msg) throw() {_msg=msg;} |
---|
| 47 | public : ~TestMorpheo (void) throw() {} |
---|
| 48 | public : const char* what () const throw() { return ( _msg.c_str() );} |
---|
[3] | 49 | }; |
---|
| 50 | |
---|
[2] | 51 | }; // end namespace morpheo |
---|
| 52 | |
---|
| 53 | #endif |
---|