Isis 3 Developer Reference
IException.h
Go to the documentation of this file.
1 #ifndef IException_h
2 #define IException_h
3 
27 #include <exception>
28 #include <string>
29 
30 #include "FileName.h"
31 
32 template <typename T> class QList;
33 
34 class QString;
35 
40 #define _FILEINFO_ Isis::FileName(__FILE__).name().toStdString().c_str(),__LINE__
41 
42 namespace Isis {
43  class Pvl;
44 
107  class IException : public std::exception {
108  public:
117  /*
118  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
119  * If at all possible do not change the enumeration values for the
120  * error codes. The reason why is it that will change the return
121  * status of error messages. Ground data processing groups (e.g.,
122  * HiRISE, LROC, Messenger) will sometime test on the error return
123  * values in their scripts. By keeping the enumerations the same
124  * we improve backward compatibility.
125  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
126  */
127  enum ErrorType {
134  Unknown = 1,
135 
143 
163 
172  };
173 
174  IException();
175 
176  IException(ErrorType type, const char *message,
177  const char *fileName, int lineNumber);
178 
179  IException(ErrorType type, const std::string &message,
180  const char *fileName, int lineNumber);
181 
182  IException(ErrorType type, const QString &message,
183  const char *fileName, int lineNumber);
184 
185  IException(const IException &caughtException,
186  ErrorType newExceptionType, const char *message,
187  const char *fileName, int lineNumber);
188 
189  IException(const IException &caughtException,
190  ErrorType newExceptionType, const std::string &message,
191  const char *fileName, int lineNumber);
192 
193  IException(const IException &caughtException,
194  ErrorType newExceptionType, const QString &message,
195  const char *fileName, int lineNumber);
196 
197  IException(const IException &other);
198 
199  ~IException() throw();
200 
201  const char *what() const throw();
202 
203  void append(const IException &exceptionSource);
204 
205  ErrorType errorType() const;
206  static QString errorTypeToString(ErrorType t);
207  void print() const;
208  void print(bool printFileInfo) const;
209  Pvl toPvl() const;
210  QString toString() const;
211  QString toString(bool printFileInfo) const;
212 
213  void swap(IException &other);
214  IException &operator=(const IException &rhs);
215 
216  private:
217  static IException createStackTrace();
218  static ErrorType stringToErrorType(const QString &s);
219  char *buildWhat() const;
220  void deleteEmptyMemberStrings();
221 
222  private:
229  char * m_what;
230 
235  ErrorType m_errorType;
236 
241  QString * m_message;
242 
246  QString * m_fileName;
247 
251  int m_lineNumber;
252 
256  QList<IException> * m_previousExceptions;
257  };
258 };
259 
260 #endif
const char * what() const
Returns a string representation of this exception in its current state.
Definition: IException.cpp:391
~IException()
The destructor frees memory allocated for the message, filename, and list of previous exceptions...
Definition: IException.cpp:365
void append(const IException &exceptionSource)
Appends the given exception (and its list of previous exceptions) to this exception&#39;s causational exc...
Definition: IException.cpp:425
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:162
A type of error that occurred when performing an actual I/O operation.
Definition: IException.h:171
A type of error that could only have occurred due to a mistake on the user&#39;s part (e...
Definition: IException.h:142
A type of error that cannot be classified as any of the other error types.
Definition: IException.h:134
Pvl toPvl() const
Returns a PVL object representing the contents of this exception.
Definition: IException.cpp:491
IException()
The default constructor creates an IException instance with no message, previous exceptions, or file info.
Definition: IException.cpp:56
Container for cube-like labels.
Definition: Pvl.h:135
void swap(IException &other)
Swaps the values of this instance&#39;s member data with other.
Definition: IException.cpp:658
void print() const
Prints a string representation of this exception to stderr.
Definition: IException.cpp:461
QString toString() const
Returns a string representation of this exception.
Definition: IException.cpp:553
ErrorType errorType() const
Returns the source of the error for this exception.
Definition: IException.cpp:446
ErrorType
Contains a set of exception error types.
Definition: IException.h:127
static QString errorTypeToString(ErrorType t)
Returns the source of the error in string format for the given ErrorType.
Definition: IException.cpp:714
Isis exception class.
Definition: IException.h:107
Definition: BoxcarCachingAlgorithm.h:29
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31