Isis 3.0 Programmer Reference
Back | Home
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 template <typename T> class QList;
31 
32 class QString;
33 
38 #define _FILEINFO_ __FILE__,__LINE__
39 
40 namespace Isis {
41  class Pvl;
42 
99  class IException : public std::exception {
100  public:
109  /*
110  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
111  * If at all possible do not change the enumeration values for the
112  * error codes. The reason why is it that will change the return
113  * status of error messages. Ground data processing groups (e.g.,
114  * HiRISE, LROC, Messenger) will sometime test on the error return
115  * values in their scripts. By keeping the enumerations the same
116  * we improve backward compatibility.
117  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
118  */
119  enum ErrorType {
126  Unknown = 1,
127 
135 
155 
164  };
165 
166  IException();
167 
168  IException(ErrorType type, const char *message,
169  const char *fileName, int lineNumber);
170 
171  IException(ErrorType type, const std::string &message,
172  const char *fileName, int lineNumber);
173 
174  IException(ErrorType type, const QString &message,
175  const char *fileName, int lineNumber);
176 
177  IException(const IException &caughtException,
178  ErrorType newExceptionType, const char *message,
179  const char *fileName, int lineNumber);
180 
181  IException(const IException &caughtException,
182  ErrorType newExceptionType, const std::string &message,
183  const char *fileName, int lineNumber);
184 
185  IException(const IException &caughtException,
186  ErrorType newExceptionType, const QString &message,
187  const char *fileName, int lineNumber);
188 
189  IException(const IException &other);
190 
191  ~IException() throw();
192 
193  const char *what() const throw();
194 
195  void append(const IException &exceptionSource);
196 
197  ErrorType errorType() const;
198  void print() const;
199  void print(bool printFileInfo) const;
200  Pvl toPvl() const;
201  QString toString() const;
202  QString toString(bool printFileInfo) const;
203 
204  void swap(IException &other);
205  IException &operator=(const IException &rhs);
206 
207  private:
208  static IException createStackTrace();
209  static QString errorTypeToString(ErrorType t);
210  static ErrorType stringToErrorType(const QString &s);
211  char *buildWhat() const;
213 
214  private:
221  char * m_what;
222 
228 
233  QString * m_message;
234 
238  QString * m_fileName;
239 
244 
249  };
250 };
251 
252 #endif
253 
Pvl toPvl() const
Returns a PVL object representing the contents of this exception.
Definition: IException.cpp:491
static IException createStackTrace()
Returns an IException representing the current stack, excluding this method.
Definition: IException.cpp:689
~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
ErrorType errorType() const
Returns the source of the error for this exception.
Definition: IException.cpp:446
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:154
A type of error that occurred when performing an actual I/O operation.
Definition: IException.h:163
const char * what() const
Returns a string representation of this exception in its current state.
Definition: IException.cpp:391
int m_lineNumber
The line in the source code file that threw this exception.
Definition: IException.h:243
ErrorType m_errorType
This exception&#39;s error source.
Definition: IException.h:227
void print() const
Prints a string representation of this exception to stderr.
Definition: IException.cpp:461
A type of error that could only have occurred due to a mistake on the user&#39;s part (e...
Definition: IException.h:134
A type of error that cannot be classified as any of the other error types.
Definition: IException.h:126
char * buildWhat() const
Returns a C string containing a string representation of this exception.
Definition: IException.cpp:766
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
QString * m_fileName
The source code file that threw this exception.
Definition: IException.h:238
ErrorType
Contains a set of exception error types.
Definition: IException.h:119
static QString errorTypeToString(ErrorType t)
Returns the source of the error in string format for the given ErrorType.
Definition: IException.cpp:714
QString toString() const
Returns a string representation of this exception.
Definition: IException.cpp:553
static ErrorType stringToErrorType(const QString &s)
Given a string, returns the error type associated with it.
Definition: IException.cpp:743
Isis exception class.
Definition: IException.h:99
QString * m_message
The message associated with this exception.
Definition: IException.h:233
void deleteEmptyMemberStrings()
This is a helper method for the constructors.
Definition: IException.cpp:782
char * m_what
This is used to store the return value of what() in a way that guarantees the returned data will not ...
Definition: IException.h:221
QList< IException > * m_previousExceptions
A list of exceptions that caused this exception.
Definition: IException.h:248

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:19:51