00001 00011 #ifndef EXCEPTION_H 00012 #define EXCEPTION_H 00013 00014 #include <basic.h> 00015 00017 00020 class Exception { 00021 00022 protected: 00024 W err; 00025 00026 public: 00028 00032 Exception(W e) : err(e) {} 00033 00035 00039 W getErrorCode() const { 00040 return err; 00041 } 00042 00043 }; 00044 00046 00049 class FileException : public Exception { 00050 00051 protected: 00053 W filedes; 00054 00055 public: 00057 00062 FileException(W fd, W e) : Exception(e), filedes(fd) {} 00063 00065 00069 W getFileDescripter() const { 00070 return filedes; 00071 } 00072 }; 00073 00075 00078 class FileOpenException : public FileException { 00079 00080 public: 00082 00087 FileOpenException(W fd, W e) : FileException(fd, e) {} 00088 }; 00089 00091 00094 class FileReadException : public FileException { 00095 00096 public: 00098 00103 FileReadException(W fd, W e) : FileException(fd, e) {} 00104 }; 00105 00107 00110 class FileWriteException : public FileException { 00111 00112 public: 00114 00119 FileWriteException(W fd, W e) : FileException(fd, e) {} 00120 }; 00121 00123 00126 class UserException : public Exception { 00127 00128 public: 00130 00134 UserException(W e = 0) : Exception(e) {} 00135 00136 }; 00137 00139 00143 class FailureException : public UserException { 00144 00145 public: 00147 00151 FailureException(W e = 0) : UserException(e) {} 00152 00157 virtual void errorPanel() const = 0; 00158 }; 00159 00161 00165 class MessagedFailureException : public FailureException { 00166 00167 protected: 00169 const TC* message; 00170 00171 public: 00177 MessagedFailureException(const TC* msg, W e = 0) 00178 : FailureException(e), message(msg) {} 00179 00184 const TC* what() const { 00185 return message; 00186 } 00187 00188 virtual void errorPanel() const; 00189 00190 }; 00191 00193 00197 class PaneledFailureException : public FailureException { 00198 00199 protected: 00201 W dbox_index; 00202 00203 public: 00209 PaneledFailureException(W db, W e = 0) 00210 : FailureException(e), dbox_index(db) {} 00211 00212 virtual void errorPanel() const; 00213 }; 00214 00215 #endif // EXCEPTION_H