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
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;
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 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
QString * m_message
The message associated with this exception.
Definition IException.h:225
IException()
The default constructor creates an IException instance with no message, previous exceptions,...
int m_lineNumber
The line in the source code file that threw this exception.
Definition IException.h:235
static QString errorTypeToString(ErrorType t)
Returns the source of the error in string format for the given ErrorType.
const char * what() const
Returns a string representation of this exception in its current state.
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
ErrorType errorType() const
Returns the source of the error for this exception.
QString toString() const
Returns a string representation of this exception.
QList< IException > * m_previousExceptions
A list of exceptions that caused this exception.
Definition IException.h:240
ErrorType m_errorType
This exception's error source.
Definition IException.h:219
void append(const IException &exceptionSource)
Appends the given exception (and its list of previous exceptions) to this exception's causational exc...
void print() const
Prints a string representation of this exception to stderr.
Pvl toPvl() const
Returns a PVL object representing the contents of this exception.
char * buildWhat() const
Returns a C string containing a string representation of this exception.
~IException()
The destructor frees memory allocated for the message, filename, and list of previous exceptions.
void deleteEmptyMemberStrings()
This is a helper method for the constructors.
static ErrorType stringToErrorType(const QString &s)
Given a string, returns the error type associated with it.
QString * m_fileName
The source code file that threw this exception.
Definition IException.h:230
Container for cube-like labels.
Definition Pvl.h:119
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16