Isis Developer Reference
IException.h
Go to the documentation of this file.
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;
204  void deleteEmptyMemberStrings();
205 
206  private:
213  char * m_what;
214 
219  ErrorType m_errorType;
220 
225  QString * m_message;
226 
230  QString * m_fileName;
231 
235  int m_lineNumber;
236 
240  QList<IException> * m_previousExceptions;
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
FileName.h
Isis::PvlObject::findGroup
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition: PvlObject.h:129
Isis::IException::Io
@ Io
A type of error that occurred when performing an actual I/O operation.
Definition: IException.h:155
Isis::IException::print
void print() const
Prints a string representation of this exception to stderr.
Definition: IException.cpp:445
StackTrace::GetStackTrace
static void GetStackTrace(const void *)
Definition: IsisDebug.h:121
Isis::PvlKeyword
A single keyword-value pair.
Definition: PvlKeyword.h:82
QList
This is free and unencumbered software released into the public domain.
Definition: BoxcarCachingAlgorithm.h:13
Isis::IException::Unknown
@ Unknown
A type of error that cannot be classified as any of the other error types.
Definition: IException.h:118
Isis::PvlObject::groups
int groups() const
Returns the number of groups contained.
Definition: PvlObject.h:75
Isis::IException::toPvl
Pvl toPvl() const
Returns a PVL object representing the contents of this exception.
Definition: IException.cpp:475
Isis::PvlContainer::hasKeyword
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
Definition: PvlContainer.cpp:159
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
Preference.h
Isis::toString
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:211
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::PvlGroup
Contains multiple PvlContainers.
Definition: PvlGroup.h:41
Pvl.h
Isis::IException::toString
QString toString() const
Returns a string representation of this exception.
Definition: IException.cpp:537
Application.h
Isis::Application::Name
static QString Name()
Returns the name of the application.
Definition: Application.cpp:729
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::PvlObject::addGroup
void addGroup(const Isis::PvlGroup &group)
Add a group to the object.
Definition: PvlObject.h:186
IException.h
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
std
Namespace for the standard library.
Isis::IException::swap
void swap(IException &other)
Swaps the values of this instance's member data with other.
Definition: IException.cpp:642
Isis::Preference::Preferences
static Preference & Preferences(bool unitTest=false)
Definition: Preference.cpp:86
IsisDebug.h
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
Isis::IException::operator=
IException & operator=(const IException &rhs)
Assign the values of rhs to this instance.
Definition: IException.cpp:659