1 | #ifndef morpheo_ErrorMorpheo |
---|
2 | #define morpheo_ErrorMorpheo |
---|
3 | |
---|
4 | /* |
---|
5 | * $Id: ErrorMorpheo.h 82 2008-05-01 16:48:45Z rosiere $ |
---|
6 | * |
---|
7 | * [ Description ] |
---|
8 | * |
---|
9 | */ |
---|
10 | |
---|
11 | #include "ToString.h" |
---|
12 | #include <iostream> |
---|
13 | #include <exception> |
---|
14 | |
---|
15 | namespace morpheo { |
---|
16 | |
---|
17 | #define ERRORMORPHEO(funcname,msg) ErrorMorpheo(funcname,msg,__LINE__,__FILE__) |
---|
18 | |
---|
19 | class ErrorMorpheo : public std::exception |
---|
20 | { |
---|
21 | // -----[ fields ]---------------------------------------------------- |
---|
22 | private : std::string _msg; |
---|
23 | |
---|
24 | // -----[ methods ]--------------------------------------------------- |
---|
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 = toString("<%s> at line %d, in file %s : %s",funcname.c_str(),line,file.c_str(),msg.c_str()); |
---|
33 | } |
---|
34 | public : ~ErrorMorpheo (void) throw() {} |
---|
35 | public : const char* what () const throw() { return ( _msg.c_str() );} |
---|
36 | |
---|
37 | }; |
---|
38 | |
---|
39 | class TestMorpheo : public std::exception |
---|
40 | { |
---|
41 | // -----[ fields ]---------------------------------------------------- |
---|
42 | private : std::string _msg; |
---|
43 | |
---|
44 | // -----[ methods ]--------------------------------------------------- |
---|
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() );} |
---|
49 | }; |
---|
50 | |
---|
51 | }; // end namespace morpheo |
---|
52 | |
---|
53 | #endif |
---|