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
16template <typename T> class QList;
17
18class QString;
19
24#define _FILEINFO_ Isis::FileName(__FILE__).name().toStdString().c_str(),__LINE__
25
26namespace 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 */
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 exception class.
Definition IException.h:91
ErrorType
Contains a set of exception error types.
Definition IException.h:111
@ Unknown
A type of error that cannot be classified as any of the other error types.
Definition IException.h:118
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition IException.h:126
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition IException.h:146
@ Io
A type of error that occurred when performing an actual I/O operation.
Definition IException.h:155
IException()
The default constructor creates an IException instance with no message, previous exceptions,...
Definition IException.cpp:38
static QString errorTypeToString(ErrorType t)
Returns the source of the error in string format for the given ErrorType.
Definition IException.cpp:672
const char * what() const
Returns a string representation of this exception in its current state.
Definition IException.cpp:373
ErrorType errorType() const
Returns the source of the error for this exception.
Definition IException.cpp:428
QString toString() const
Returns a string representation of this exception.
Definition IException.cpp:535
void append(const IException &exceptionSource)
Appends the given exception (and its list of previous exceptions) to this exception's causational exc...
Definition IException.cpp:407
void print() const
Prints a string representation of this exception to stderr.
Definition IException.cpp:443
Pvl toPvl() const
Returns a PVL object representing the contents of this exception.
Definition IException.cpp:473
~IException()
The destructor frees memory allocated for the message, filename, and list of previous exceptions.
Definition IException.cpp:347
Container for cube-like labels.
Definition Pvl.h:119
This is free and unencumbered software released into the public domain.
Definition BoxcarCachingAlgorithm.h:13
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16