Changeset 3585 in Sophya for trunk/SophyaLib/BaseTools/pexceptions.h
- Timestamp:
- Mar 5, 2009, 2:24:17 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/BaseTools/pexceptions.h
r2505 r3585 10 10 // Petit utilitaire pour accoler numero de ligne et nom de fichier aux messages 11 11 // d'exception 12 //! Utiliy macro to append file name and line number to a const char* string 12 13 #define PExcLongMessage(a) BuildLongExceptionMessage(a,__FILE__,__LINE__) 13 14 15 #define SEXC_MAXMSGLEN 160 14 16 namespace SOPHYA { 15 17 … … 17 19 string BuildLongExceptionMessage(const char * s, const char *file, int line); 18 20 19 /*! \ingroup BaseTools 20 \brief Base exception class in Sophya 21 22 Ancestor for PError and PException 23 It has a message, and an id to give more 24 information on the exception. 25 */ 26 class PThrowable { 21 class PThrowable : public std::exception { 27 22 public: 28 23 //! Constructor with the message and error-id (optional) specification 29 explicit PThrowable(const string& m, int ident=0) 30 : msg(m), id(ident) {}31 explicit PThrowable(const char* m, int ident=0)32 : msg(m), id(ident) {}33 virtual ~PThrowable() { }24 explicit PThrowable(const string& m, int ident=0) throw() ; 25 explicit PThrowable(const char* m, int ident=0) throw() ; 26 virtual ~PThrowable() throw(); 27 //! Implementation of std::exception what() method, returning the exception message 28 virtual const char* what() const throw(); 34 29 //! Returns the associated message string 35 virtual string const & Msg() const {return msg;}30 virtual string const Msg() const; 36 31 //! Returns the associated error-id 37 virtual int Id() const {return id; }32 virtual int Id() const; 38 33 private: 39 string msg;40 int id ;34 char msg_[SEXC_MAXMSGLEN]; 35 int id_; 41 36 }; 42 37 … … 49 44 class PError : public PThrowable { 50 45 public: 51 explicit PError(const string& m, int id=0) : PThrowable(m,id) {}52 explicit PError(const char* m, int id=0) : PThrowable(m,id) {}46 explicit PError(const string& m, int id=0) throw() : PThrowable(m,id) {} 47 explicit PError(const char* m, int id=0) throw() : PThrowable(m,id) {} 53 48 }; 54 49 … … 57 52 class PException : public PThrowable { 58 53 public: 59 explicit PException(const string& m, int id=0) : PThrowable(m,id) {} 54 explicit PException(const string& m, int id=0) throw() : PThrowable(m,id) {} 55 explicit PException(const char* m, int id=0) throw() : PThrowable(m,id) {} 60 56 }; 61 57 … … 71 67 class AllocationError : public PError { 72 68 public: 73 explicit AllocationError(const string& m, int id=0) : PError(m,id) {}74 explicit AllocationError(const char* m, int id=0) : PError(m,id) {}69 explicit AllocationError(const string& m, int id=0) throw() : PError(m,id) {} 70 explicit AllocationError(const char* m, int id=0) throw() : PError(m,id) {} 75 71 }; 76 72 … … 79 75 class NullPtrError : public PError { 80 76 public: 81 explicit NullPtrError(const string& m, int id=0) : PError(m,id) {}82 explicit NullPtrError(const char* m, int id=0) : PError(m,id) {}77 explicit NullPtrError(const string& m, int id=0) throw() : PError(m,id) {} 78 explicit NullPtrError(const char* m, int id=0) throw() : PError(m,id) {} 83 79 }; 84 80 … … 88 84 class ForbiddenError : public PError { 89 85 public: 90 explicit ForbiddenError(const string& m, int id=0) : PError(m,id) {}91 explicit ForbiddenError(const char* m, int id=0) : PError(m,id) {}86 explicit ForbiddenError(const string& m, int id=0) throw() : PError(m,id) {} 87 explicit ForbiddenError(const char* m, int id=0) throw() : PError(m,id) {} 92 88 }; 93 89 … … 97 93 class AssertionFailedError : public PError { 98 94 public: 99 explicit AssertionFailedError(const string& m, int id=0) : PError(m,id) {}100 explicit AssertionFailedError(const char* m, int id=0) : PError(m,id) {}95 explicit AssertionFailedError(const string& m, int id=0) throw() : PError(m,id) {} 96 explicit AssertionFailedError(const char* m, int id=0) throw() : PError(m,id) {} 101 97 }; 102 98 … … 120 116 class IOExc : public PException { 121 117 public: 122 explicit IOExc(const string& m, int id=0) : PException(m,id) {}123 explicit IOExc(const char* m, int id=0) : PException(m,id) {}118 explicit IOExc(const string& m, int id=0) throw() : PException(m,id) {} 119 explicit IOExc(const char* m, int id=0) throw() : PException(m,id) {} 124 120 }; 125 121 … … 128 124 class FileFormatExc : public IOExc { 129 125 public: 130 explicit FileFormatExc(const string& m, int id=0) : IOExc(m,id) {}131 explicit FileFormatExc(const char* m, int id=0) : IOExc(m,id) {}126 explicit FileFormatExc(const string& m, int id=0) throw() : IOExc(m,id) {} 127 explicit FileFormatExc(const char* m, int id=0) throw() : IOExc(m,id) {} 132 128 }; 133 129 … … 136 132 class SzMismatchError : public PException { 137 133 public: 138 explicit SzMismatchError(const string& m, int id=0) : PException(m,id) {}139 explicit SzMismatchError(const char* m, int id=0) : PException(m,id) {}134 explicit SzMismatchError(const string& m, int id=0) throw() : PException(m,id) {} 135 explicit SzMismatchError(const char* m, int id=0) throw() : PException(m,id) {} 140 136 }; 141 137 … … 144 140 class RangeCheckError : public PException { 145 141 public: 146 explicit RangeCheckError(const string& m, int id=0) : PException(m,id) {}147 explicit RangeCheckError(const char* m, int id=0) : PException(m,id) {}142 explicit RangeCheckError(const string& m, int id=0) throw() : PException(m,id) {} 143 explicit RangeCheckError(const char* m, int id=0) throw() : PException(m,id) {} 148 144 }; 149 145 … … 152 148 class ParmError : public PException { 153 149 public: 154 explicit ParmError(const string& m, int id=0) : PException(m,id) {}155 explicit ParmError(const char* m, int id=0) : PException(m,id) {}150 explicit ParmError(const string& m, int id=0) throw() : PException(m,id) {} 151 explicit ParmError(const char* m, int id=0) throw() : PException(m,id) {} 156 152 }; 157 153 … … 160 156 class NotAvailableOperation : public PException { 161 157 public: 162 explicit NotAvailableOperation(const string& m, int id=0) : PException(m,id) {}163 explicit NotAvailableOperation(const char* m, int id=0) : PException(m,id) {}158 explicit NotAvailableOperation(const string& m, int id=0) throw() : PException(m,id) {} 159 explicit NotAvailableOperation(const char* m, int id=0) throw() : PException(m,id) {} 164 160 }; 165 161 … … 168 164 class TypeMismatchExc : public PException { 169 165 public: 170 explicit TypeMismatchExc(const string& m, int id=0) : PException(m,id) {}171 explicit TypeMismatchExc(const char* m, int id=0) : PException(m,id) {}166 explicit TypeMismatchExc(const string& m, int id=0) throw() : PException(m,id) {} 167 explicit TypeMismatchExc(const char* m, int id=0) throw() : PException(m,id) {} 172 168 }; 173 169 … … 176 172 class MathExc : public PException { 177 173 public: 178 explicit MathExc(const string& m, int id=0) : PException(m,id) {}179 explicit MathExc(const char* m, int id=0) : PException(m,id) {}174 explicit MathExc(const string& m, int id=0) throw() : PException(m,id) {} 175 explicit MathExc(const char* m, int id=0) throw() : PException(m,id) {} 180 176 }; 181 177 … … 184 180 class SingMatrixExc : public MathExc { 185 181 public: 186 explicit SingMatrixExc(const string& m, int id=0) : MathExc(m,id) {}187 explicit SingMatrixExc(const char* m, int id=0) : MathExc(m,id) {}182 explicit SingMatrixExc(const string& m, int id=0) throw() : MathExc(m,id) {} 183 explicit SingMatrixExc(const char* m, int id=0) throw() : MathExc(m,id) {} 188 184 }; 189 185 … … 192 188 class DuplicateIdExc : public PException { 193 189 public: 194 explicit DuplicateIdExc(const string& m, int id=0) : PException(m,id) {}195 explicit DuplicateIdExc(const char* m, int id=0) : PException(m,id) {}190 explicit DuplicateIdExc(const string& m, int id=0) throw() : PException(m,id) {} 191 explicit DuplicateIdExc(const char* m, int id=0) throw() : PException(m,id) {} 196 192 }; 197 193 … … 200 196 class NotFoundExc : public PException { 201 197 public: 202 explicit NotFoundExc(const string& m, int id=0) : PException(m,id) {}203 explicit NotFoundExc(const char* m, int id=0) : PException(m,id) {}198 explicit NotFoundExc(const string& m, int id=0) throw() : PException(m,id) {} 199 explicit NotFoundExc(const char* m, int id=0) throw() : PException(m,id) {} 204 200 }; 205 201 … … 208 204 class CaughtSignalExc : public PException { 209 205 public: 210 explicit CaughtSignalExc(const string& m, int id=0) : PException(m,id) {}211 explicit CaughtSignalExc(const char* m, int id=0) : PException(m,id) {}206 explicit CaughtSignalExc(const string& m, int id=0) throw() : PException(m,id) {} 207 explicit CaughtSignalExc(const char* m, int id=0) throw() : PException(m,id) {} 212 208 }; 213 209 … … 223 219 {if (!(_x_)) throw(NullPtrError(#_x_))} 224 220 225 void InitFailNewHandler(); 226 221 227 222 228 // Compatibility with EROS-PEIDA exceptions229 230 231 #define TRY try232 #define CATCH(_var) catch(long _var)233 #define CATCHALL catch(...)234 #define ENDTRY235 236 #define THROW(_i) throw( _i);237 238 #define THROW_ THROW(0)239 240 #define THROW_SAME throw;241 242 243 #define DBASSERT(_x_) ASSERT(_x_)244 245 223 #endif
Note:
See TracChangeset
for help on using the changeset viewer.