Isis 3.0 Developer's Reference (API) |
Home |
00001 #ifndef IException_h 00002 #define IException_h 00003 00027 #include <exception> 00028 #include <string> 00029 00030 template <typename T> class QList; 00031 00032 class QString; 00033 00038 #define _FILEINFO_ __FILE__,__LINE__ 00039 00040 namespace Isis { 00041 class Pvl; 00042 00099 class IException : public std::exception { 00100 public: 00109 /* 00110 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING 00111 * If at all possible do not change the enumeration values for the 00112 * error codes. The reason why is it that will change the return 00113 * status of error messages. Ground data processing groups (e.g., 00114 * HiRISE, LROC, Messenger) will sometime test on the error return 00115 * values in their scripts. By keeping the enumerations the same 00116 * we improve backward compatibility. 00117 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING 00118 */ 00119 enum ErrorType { 00126 Unknown = 1, 00127 00134 User, 00135 00154 Programmer, 00155 00163 Io 00164 }; 00165 00166 IException(); 00167 00168 IException(ErrorType type, const char *message, 00169 const char *fileName, int lineNumber); 00170 00171 IException(ErrorType type, const std::string &message, 00172 const char *fileName, int lineNumber); 00173 00174 IException(ErrorType type, const QString &message, 00175 const char *fileName, int lineNumber); 00176 00177 IException(const IException &caughtException, 00178 ErrorType newExceptionType, const char *message, 00179 const char *fileName, int lineNumber); 00180 00181 IException(const IException &caughtException, 00182 ErrorType newExceptionType, const std::string &message, 00183 const char *fileName, int lineNumber); 00184 00185 IException(const IException &caughtException, 00186 ErrorType newExceptionType, const QString &message, 00187 const char *fileName, int lineNumber); 00188 00189 IException(const IException &other); 00190 00191 ~IException() throw(); 00192 00193 const char *what() const throw(); 00194 00195 void append(const IException &exceptionSource); 00196 00197 ErrorType errorType() const; 00198 void print() const; 00199 void print(bool printFileInfo) const; 00200 Pvl toPvl() const; 00201 QString toString() const; 00202 QString toString(bool printFileInfo) const; 00203 00204 void swap(IException &other); 00205 IException &operator=(const IException &rhs); 00206 00207 private: 00208 static IException createStackTrace(); 00209 static QString errorTypeToString(ErrorType t); 00210 static ErrorType stringToErrorType(const QString &s); 00211 char *buildWhat() const; 00212 void deleteEmptyMemberStrings(); 00213 00214 private: 00221 char * m_what; 00222 00227 ErrorType m_errorType; 00228 00233 QString * m_message; 00234 00238 QString * m_fileName; 00239 00243 int m_lineNumber; 00244 00248 QList<IException> * m_previousExceptions; 00249 }; 00250 }; 00251 00252 #endif 00253