[219] | 1 | #ifndef PERRORS_SEEN
|
---|
| 2 | #define PERRORS_SEEN
|
---|
| 3 |
|
---|
| 4 | // Erreurs PEIDA
|
---|
| 5 | // Les erreurs graves sont negatives. Par defaut elles causent
|
---|
| 6 | // un abort, alors que les erreurs positives propagent une
|
---|
| 7 | // exception.
|
---|
| 8 | // voir les macros EXC_ABORT_NEG(flag) et EXC_ABORT_ALL(flag)
|
---|
| 9 |
|
---|
| 10 | #include "exceptions.h"
|
---|
| 11 | enum {
|
---|
| 12 | allocationErr = -1,
|
---|
| 13 | nullPtrErr = -2,
|
---|
| 14 | sizeMismatchErr = -3,
|
---|
| 15 | rangeCheckErr = -4,
|
---|
| 16 | parmErr = -5,
|
---|
| 17 | forbiddenErr = -6,
|
---|
| 18 | assertionFailErr = -7,
|
---|
| 19 |
|
---|
| 20 | typeMismatchErr = 1,
|
---|
| 21 | fileErr ,
|
---|
| 22 | fitsImageErr ,
|
---|
| 23 | endOfFileErr ,
|
---|
| 24 | tapeErr ,
|
---|
| 25 | tapeNoLogErr ,
|
---|
| 26 | tapeNoLabelErr ,
|
---|
| 27 | tapeEndMediaErr ,
|
---|
| 28 | tapeNotReadyErr ,
|
---|
| 29 | acqTapeErr ,
|
---|
| 30 | acqRobotErr ,
|
---|
| 31 | tarFileErr ,
|
---|
| 32 | tarFileNoHeaderErr ,
|
---|
| 33 | noStarsErr ,
|
---|
| 34 | transfoErr ,
|
---|
| 35 | fitsHeaderErr ,
|
---|
| 36 | singMatxErr ,
|
---|
| 37 | noCvgErr ,
|
---|
| 38 | notFoundErr ,
|
---|
| 39 | dupIdErr ,
|
---|
| 40 | getEnvErr ,
|
---|
| 41 | catchedSIGFPE ,
|
---|
| 42 | catchedSIGSEGV ,
|
---|
| 43 | catchedSIGINT ,
|
---|
| 44 | catchedSIGQUIT ,
|
---|
| 45 | catchedSIGUSR1 ,
|
---|
| 46 | catchedSIGUSR2 ,
|
---|
| 47 | inconsistentErr
|
---|
| 48 | };
|
---|
| 49 |
|
---|
| 50 | static inline char* PeidaExc(int i) {
|
---|
| 51 | switch (i) {
|
---|
| 52 | case allocationErr: return "Allocation Exception";
|
---|
| 53 | case nullPtrErr: return "Null Pointer Exception";
|
---|
| 54 | case sizeMismatchErr: return "Size Mismatch Exception";
|
---|
| 55 | case rangeCheckErr: return "Range Check Exception";
|
---|
| 56 | case parmErr: return "Invalid Parameter Exception";
|
---|
| 57 | case forbiddenErr: return "Forbidden Function Exception";
|
---|
| 58 | case assertionFailErr: return "Assertion Failed Exception";
|
---|
| 59 | case typeMismatchErr: return "Type Mismatch Exception";
|
---|
| 60 | case fileErr: return "File Error Exception";
|
---|
| 61 | case fitsImageErr: return "FitsImage Error Exception";
|
---|
| 62 | case endOfFileErr: return "End of File Error Exception";
|
---|
| 63 | case tapeErr: return "Tape Error Exception";
|
---|
| 64 | case tapeNoLogErr: return "Tape No Log File Exception";
|
---|
| 65 | case tapeNoLabelErr: return "Tape No label Exception";
|
---|
| 66 | case tapeEndMediaErr: return "Tape end data Exception";
|
---|
| 67 | case tapeNotReadyErr: return "Tape not ready Exception";
|
---|
| 68 | case acqTapeErr: return "Acq Tape Error Exception";
|
---|
| 69 | case acqRobotErr: return "Acq Robot Error Exception";
|
---|
| 70 | case tarFileErr: return "TarFile Error Exception";
|
---|
| 71 | case tarFileNoHeaderErr: return "TarFile No Header Error Exception";
|
---|
| 72 | case noStarsErr: return "No/Not Enough Stars Exception";
|
---|
| 73 | case transfoErr: return "Transformation finding Exception";
|
---|
| 74 | case fitsHeaderErr: return "Fits Header Exception";
|
---|
| 75 | case singMatxErr: return "Singular Matrix Exception";
|
---|
| 76 | case noCvgErr: return "No Convergence Exception";
|
---|
| 77 | case notFoundErr: return "Not Found Exception";
|
---|
| 78 | case dupIdErr: return "Duplicate Id Exception";
|
---|
| 79 | case getEnvErr: return "GetEnv no var Exception";
|
---|
| 80 | case inconsistentErr: return "Inconsistent Data Exception";
|
---|
| 81 | case catchedSIGFPE: return "catched SIGFPE (floating point exception) Exception";
|
---|
| 82 | case catchedSIGSEGV: return "catched SIGSEGV (segmentation fault) Exception";
|
---|
| 83 | case catchedSIGINT: return "catched SIGINT (Interrupt signal) Exception";
|
---|
| 84 | case catchedSIGQUIT: return "catched SIGQUIT (Quit signal) Exception";
|
---|
| 85 | case catchedSIGUSR1: return "catched SIGUSR1 (User1 signal) Exception";
|
---|
| 86 | case catchedSIGUSR2: return "catched SIGUSR2 (User2 signal) Exception";
|
---|
| 87 | }
|
---|
| 88 | return "Unkown Exception";
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 |
|
---|
| 92 | #define FAILNIL(_x_) \
|
---|
| 93 | if (!(_x_)) THROW(nullPtrErr)
|
---|
| 94 |
|
---|
| 95 | #define EXC_MSG(i) PeidaExc(i) << "(" << i << ")"
|
---|
| 96 |
|
---|
| 97 | #ifdef DEBUG
|
---|
| 98 | #define DBFAILNIL(_x_) FAILNIL(_x_)
|
---|
| 99 | #define DBASSERT(_x_) ASSERT(_x_)
|
---|
| 100 | #else
|
---|
| 101 | #define DBFAILNIL(_x_)
|
---|
| 102 | #define DBASSERT(_x_)
|
---|
| 103 | #endif
|
---|
| 104 |
|
---|
| 105 | #endif
|
---|