Changeset 256 in Sophya for trunk/SophyaLib/BaseTools/pexceptions.h
- Timestamp:
- Apr 23, 1999, 2:38:18 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaLib/BaseTools/pexceptions.h
r251 r256 4 4 5 5 #include "machdefs.h" 6 //#include <exception>7 6 #include <string> 8 7 … … 12 11 13 12 // Ancestor for PError and PException 14 class PThrowable { // : public exception { 15 public: 16 explicit PThrowable(const string& m) : msg(m) {} 17 virtual ~PThrowable() { } 18 virtual string const& Msg() const {return msg;} 19 private: 20 string msg; 13 // It has a message, and an id to give more 14 // information on the exception. 15 class PThrowable { 16 public: 17 explicit PThrowable(const string& m, int ident=0) 18 : msg(m), id(ident) {} 19 virtual ~PThrowable() { } 20 virtual string const& Msg() const {return msg;} 21 private: 22 string msg; 23 int id; 21 24 }; 22 25 23 26 // A PError is a serious logic error. Usually not caught... 24 27 class PError : public PThrowable { 25 26 explicit PError(const string& m) : PThrowable(m) {}28 public: 29 explicit PError(const string& m, int id=0) : PThrowable(m,id) {} 27 30 }; 28 31 29 32 // A PException is not as serious... Can be caught. 30 33 class PException : public PThrowable { 31 public: 32 explicit PException(const string& m) : PThrowable(m) {} 34 public: 35 explicit PException(const string& m, int id=0) : PThrowable(m,id) {} 36 }; 37 38 // Errors 39 // Memory allocation failure 40 class AllocationError : public PError { 41 public: 42 explicit AllocationError(const string& m, int id=0) : PError(m,id) {} 43 }; 44 45 // Null pointer error 46 class NullPtrError : public PError { 47 public: 48 explicit NullPtrError(const string& m, int id=0) : PError(m,id) {} 49 }; 50 51 // Size mismatch between objects 52 class SzMismatchError : public PError { 53 public: 54 explicit SzMismatchError(const string& m, int id=0) : PError(m,id) {} 55 }; 56 57 // Out of bounds for array, matrix, etc. 58 class RangeCheckError : public PError { 59 public: 60 explicit RangeCheckError(const string& m, int id=0) : PError(m,id) {} 61 }; 62 63 // Invalid parameter to method/constructor... 64 class ParmError : public PError { 65 public: 66 explicit ParmError(const string& m, int id=0) : PError(m,id) {} 67 }; 68 69 // Calling a forbidden method, trying a forbidden operation 70 class ForbiddenError : public PError { 71 public: 72 explicit ForbiddenError(const string& m, int id=0) : PError(m,id) {} 73 }; 74 75 // ASSERT macro failure. The message is the assertion... 76 class AssertionFailedError : public PError { 77 public: 78 explicit AssertionFailedError(const string& m, int id=0) : PError(m,id) {} 79 }; 80 81 // Standard exceptions 82 // 83 // PException 84 // IOExc 85 // FileFormatExc 86 // TypeMismatchExc 87 // DuplicateIdExc 88 // NotFoundExc 89 // MathExc 90 // SingMatxExc 91 92 // generic IO Exception 93 class IOExc : public PException { 94 public: 95 explicit IOExc(const string& m, int id=0) : PException(m,id) {} 33 96 }; 34 97 35 // Errors36 class AllocationError : public PError{37 38 explicit AllocationError(const string& m) : PError(m) {}98 // Bad type -> keep ? 99 class TypeMismatchExc : public PException { 100 public: 101 explicit TypeMismatchExc(const string& m, int id=0) : PException(m,id) {} 39 102 }; 40 103 41 class NullPtrError : public PError { 42 public: 43 explicit NullPtrError(const string& m) : PError(m) {} 104 class MathExc : public PException { 105 public: 106 explicit MathExc(const string& m, int id=0) : PException(m,id) {} 107 }; 108 109 class DuplicateIdExc : public PException { 110 public: 111 explicit DuplicateIdExc(const string& m, int id=0) : PException(m,id) {} 112 }; 113 114 class NotFoundExc : public PException { 115 public: 116 explicit NotFoundExc(const string& m, int id=0) : PException(m,id) {} 117 }; 118 119 class CaughtSignalExc : public PException { 120 public: 121 explicit CaughtSignalExc(const string& m, int id=0) : PException(m,id) {} 44 122 }; 45 123 46 class SzMismatchError : public PError { 47 public: 48 explicit SzMismatchError(const string& m) : PError(m) {} 49 }; 50 51 class RangeCheckError : public PError { 52 public: 53 explicit RangeCheckError(const string& m) : PError(m) {} 54 }; 55 56 class ParmError : public PError { 57 public: 58 explicit ParmError(const string& m) : PError(m) {} 59 }; 60 61 class ForbiddenError : public PError { 62 public: 63 explicit ForbiddenError(const string& m) : PError(m) {} 64 }; 65 66 class AssertionFailedError : public PError { 67 public: 68 explicit AssertionFailedError(const string& m) : PError(m) {} 69 }; 70 71 // Standard exceptions 72 class TypeMismatchExc : public PException { 73 public: 74 explicit TypeMismatchExc(const string& m) : PException(m) {} 75 }; 76 77 class FileExc : public PException { 78 public: 79 explicit FileExc(const string& m) : PException(m) {} 80 }; 81 82 class FileFormatExc : public PException { 83 public: 84 explicit FileFormatExc(const string& m) : PException(m) {} 85 }; 86 87 class DuplicateIdExc : public PException { 88 public: 89 explicit DuplicateIdExc(const string& m) : PException(m) {} 90 }; 91 92 class NotFoundExc : public PException { 93 public: 94 explicit NotFoundExc(const string& m) : PException(m) {} 95 }; 96 97 class CaughtSignalExc : public PException { 98 public: 99 explicit CaughtSignalExc(const string& m) : PException(m) {} 124 // Bad file format 125 class FileFormatExc : public IOExc { 126 public: 127 explicit FileFormatExc(const string& m, int id=0) : IOExc(m,id) {} 100 128 }; 101 129 102 class SingMatrixExc : public PException{103 104 explicit SingMatrixExc(const string& m) : PException(m) {}130 class SingMatrixExc : public MathExc { 131 public: 132 explicit SingMatrixExc(const string& m, int id=0) : MathExc(m,id) {} 105 133 }; 106 134 107 135 108 136 } 109 137 … … 149 177 #define inconsistentErr ParmError("") 150 178 #define sizeMismatchErr SzMismatchError("") 151 #define fileErr FileExc("")179 #define fileErr IOExc("") 152 180 #define nullPtrErr NullPtrError("") 153 181 #define singMatxErr SingMatrixExc("")
Note:
See TracChangeset
for help on using the changeset viewer.