Isis 3 Programmer Reference
IException.h
1 #ifndef IException_h
2 #define IException_h
3 
9 /* SPDX-License-Identifier: CC0-1.0 */
10 
11 #include <exception>
12 #include <string>
13 
14 #include "FileName.h"
15 
16 template <typename T> class QList;
17 
18 class QString;
19 
24 #define _FILEINFO_ Isis::FileName(__FILE__).name().toStdString().c_str(),__LINE__
25 
26 namespace Isis {
27  class Pvl;
28 
91  class IException : public std::exception {
92  public:
101  /*
102  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
103  * If at all possible do not change the enumeration values for the
104  * error codes. The reason why is it that will change the return
105  * status of error messages. Ground data processing groups (e.g.,
106  * HiRISE, LROC, Messenger) will sometime test on the error return
107  * values in their scripts. By keeping the enumerations the same
108  * we improve backward compatibility.
109  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
110  */
111  enum ErrorType {
118  Unknown = 1,
119 
127 
147 
155  Io
156  };
157 
158  IException();
159 
160  IException(ErrorType type, const char *message,
161  const char *fileName, int lineNumber);
162 
163  IException(ErrorType type, const std::string &message,
164  const char *fileName, int lineNumber);
165 
166  IException(ErrorType type, const QString &message,
167  const char *fileName, int lineNumber);
168 
169  IException(const IException &caughtException,
170  ErrorType newExceptionType, const char *message,
171  const char *fileName, int lineNumber);
172 
173  IException(const IException &caughtException,
174  ErrorType newExceptionType, const std::string &message,
175  const char *fileName, int lineNumber);
176 
177  IException(const IException &caughtException,
178  ErrorType newExceptionType, const QString &message,
179  const char *fileName, int lineNumber);
180 
181  IException(const IException &other);
182 
183  ~IException() throw();
184 
185  const char *what() const throw();
186 
187  void append(const IException &exceptionSource);
188 
189  ErrorType errorType() const;
190  static QString errorTypeToString(ErrorType t);
191  void print() const;
192  void print(bool printFileInfo) const;
193  Pvl toPvl() const;
194  QString toString() const;
195  QString toString(bool printFileInfo) const;
196 
197  void swap(IException &other);
198  IException &operator=(const IException &rhs);
199 
200  private:
201  static IException createStackTrace();
202  static ErrorType stringToErrorType(const QString &s);
203  char *buildWhat() const;
205 
206  private:
213  char * m_what;
214 
220 
225  QString * m_message;
226 
230  QString * m_fileName;
231 
236 
241  };
242 };
243 
244 #endif
Isis::IException::IException
IException()
The default constructor creates an IException instance with no message, previous exceptions,...
Definition: IException.cpp:40
Isis::IException::errorTypeToString
static QString errorTypeToString(ErrorType t)
Returns the source of the error in string format for the given ErrorType.
Definition: IException.cpp:698
Isis::IException::Io
@ Io
A type of error that occurred when performing an actual I/O operation.
Definition: IException.h:155
Isis::IException::m_what
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:213
Isis::IException::print
void print() const
Prints a string representation of this exception to stderr.
Definition: IException.cpp:445
Isis::IException::m_lineNumber
int m_lineNumber
The line in the source code file that threw this exception.
Definition: IException.h:235
Isis::IException::deleteEmptyMemberStrings
void deleteEmptyMemberStrings()
This is a helper method for the constructors.
Definition: IException.cpp:766
QList
This is free and unencumbered software released into the public domain.
Definition: BoxcarCachingAlgorithm.h:13
Isis::IException::m_message
QString * m_message
The message associated with this exception.
Definition: IException.h:225
Isis::IException::Unknown
@ Unknown
A type of error that cannot be classified as any of the other error types.
Definition: IException.h:118
Isis::IException::toPvl
Pvl toPvl() const
Returns a PVL object representing the contents of this exception.
Definition: IException.cpp:475
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::IException::~IException
~IException()
The destructor frees memory allocated for the message, filename, and list of previous exceptions.
Definition: IException.cpp:349
Isis::IException::stringToErrorType
static ErrorType stringToErrorType(const QString &s)
Given a string, returns the error type associated with it.
Definition: IException.cpp:727
Isis::IException::what
const char * what() const
Returns a string representation of this exception in its current state.
Definition: IException.cpp:375
Isis::IException::append
void append(const IException &exceptionSource)
Appends the given exception (and its list of previous exceptions) to this exception's causational exc...
Definition: IException.cpp:409
Isis::IException::buildWhat
char * buildWhat() const
Returns a C string containing a string representation of this exception.
Definition: IException.cpp:750
Isis::IException::createStackTrace
static IException createStackTrace()
Returns an IException representing the current stack, excluding this method.
Definition: IException.cpp:673
Isis::IException::toString
QString toString() const
Returns a string representation of this exception.
Definition: IException.cpp:537
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::IException::errorType
ErrorType errorType() const
Returns the source of the error for this exception.
Definition: IException.cpp:430
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
Isis::IException::swap
void swap(IException &other)
Swaps the values of this instance's member data with other.
Definition: IException.cpp:642
Isis::IException::m_errorType
ErrorType m_errorType
This exception's error source.
Definition: IException.h:219
Isis::IException::m_fileName
QString * m_fileName
The source code file that threw this exception.
Definition: IException.h:230
Isis::IException::m_previousExceptions
QList< IException > * m_previousExceptions
A list of exceptions that caused this exception.
Definition: IException.h:240
Isis::IException::ErrorType
ErrorType
Contains a set of exception error types.
Definition: IException.h:111
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::IException::User
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition: IException.h:126