24 #include "IsisDebug.h" 
   56   IException::IException() {
 
   58     m_errorType = Unknown;
 
   61     m_previousExceptions = NULL;
 
   88   IException::IException(
ErrorType type, 
const QString &message,
 
   89                          const char *fileName, 
int lineNumber) {
 
   93     m_previousExceptions = NULL;
 
   96     m_message = 
new QString(QString(message).trimmed());
 
   97     m_fileName = 
new QString(fileName);
 
   98     m_lineNumber = lineNumber;
 
  100     deleteEmptyMemberStrings();
 
  102     m_what = buildWhat();
 
  126   IException::IException(
ErrorType type, 
const char *message,
 
  127                          const char *fileName, 
int lineNumber) {
 
  131     m_previousExceptions = NULL;
 
  134     m_message = 
new QString(QString(message).trimmed());
 
  135     m_fileName = 
new QString(fileName);
 
  136     m_lineNumber = lineNumber;
 
  138     deleteEmptyMemberStrings();
 
  140     m_what = buildWhat();
 
  164   IException::IException(
ErrorType type, 
const std::string &message,
 
  165                          const char *fileName, 
int lineNumber) {
 
  169     m_previousExceptions = NULL;
 
  172     m_message = 
new QString(QString(message.c_str()).trimmed());
 
  173     m_fileName = 
new QString(fileName);
 
  174     m_lineNumber = lineNumber;
 
  176     deleteEmptyMemberStrings();
 
  178     m_what = buildWhat();
 
  214       const char *fileName, 
int lineNumber) {
 
  218     m_previousExceptions = NULL;
 
  221     m_message = 
new QString(QString(message).trimmed());
 
  222     m_fileName = 
new QString(fileName);
 
  223     m_lineNumber = lineNumber;
 
  225     deleteEmptyMemberStrings();
 
  227     append(caughtException);
 
  261       ErrorType type, 
const std::string &message,
 
  262       const char *fileName, 
int lineNumber) {
 
  266     m_previousExceptions = NULL;
 
  269     m_message = 
new QString(QString(message.c_str()).trimmed());
 
  270     m_fileName = 
new QString(fileName);
 
  271     m_lineNumber = lineNumber;
 
  273     deleteEmptyMemberStrings();
 
  275     append(caughtException);
 
  309       const char *fileName, 
int lineNumber) {
 
  313     m_previousExceptions = NULL;
 
  316     m_message = 
new QString(message.trimmed());
 
  317     m_fileName = 
new QString(fileName);
 
  318     m_lineNumber = lineNumber;
 
  320     deleteEmptyMemberStrings();
 
  322     append(caughtException);
 
  331   IException::IException(
const IException &other) : exception(other) {
 
  341       int length = strlen(other.
m_what);
 
  342       m_what = 
new char[length + 1];
 
  463     if (errorString != 
"")
 
  464       cerr << errorString.toLatin1().data() << endl;
 
  478     QString errorString = 
toString(printFileInfo);
 
  479     if (errorString != 
"")
 
  480       cerr << errorString.toLatin1().data() << endl;
 
  499     exceptionsToConvert.append(*
this);
 
  501     for (
int exceptionIndex = exceptionsToConvert.size() - 1;
 
  504       const IException &exception(exceptionsToConvert.at(exceptionIndex));
 
  506       bool exceptionIsBlank = 
true;
 
  511       if (exception.m_errorType != 
Unknown) {
 
  514         exceptionIsBlank = 
false;
 
  519       if (exception.m_message) {
 
  520         exceptionIsBlank = 
false;
 
  521         QString message(*exception.m_message);
 
  523         if (message.size() && message[message.size() - 1] == 
'.')
 
  524           message = message.mid(0, message.size() - 1);
 
  528       if (exception.m_fileName) {
 
  529         exceptionIsBlank = 
false;
 
  530         errGroup += 
PvlKeyword(
"File", *exception.m_fileName);
 
  532         if (exception.m_lineNumber != -1)
 
  536       if (!exceptionIsBlank)
 
  554     bool reportFileLine = 
true;
 
  556     if (Preference::Preferences().hasGroup(
"ErrorFacility")) {
 
  558           Preference::Preferences().findGroup(
"ErrorFacility");
 
  560         QString fileLine = errorFacility[
"FileLine"][0];
 
  561         reportFileLine = (fileLine.toUpper() == 
"ON");
 
  583     bool usePvlFormat = 
false;
 
  585     if (Preference::Preferences().hasGroup(
"ErrorFacility")) {
 
  587           Preference::Preferences().findGroup(
"ErrorFacility");
 
  589         QString format = errorFacility[
"Format"][0];
 
  590         usePvlFormat = (format.toUpper() == 
"PVL");
 
  597       if (errors.
groups() != 0) {
 
  598         stringstream stringStream;
 
  599         stringStream << errors;
 
  600         result = stringStream.str().c_str();
 
  609       exceptionsToConvert.append(*
this);
 
  611       for (
int exceptionIndex = exceptionsToConvert.size() - 1;
 
  614         const IException &exception(exceptionsToConvert.at(exceptionIndex));
 
  617         if (exception.m_errorType != 
Unknown || exception.m_message) {
 
  621         bool needsPeriod = 
false;
 
  622         if (exception.m_message) {
 
  623           QString message(*exception.m_message);
 
  625           if (message.size() && message[message.size() - 1] == 
'.')
 
  626             message = message.mid(0, message.size() - 1);
 
  629           result += 
" " + message;
 
  633         if(includeFileInfo && exception.m_fileName) {
 
  634           result += 
" in " + *exception.m_fileName;
 
  635           if (exception.m_lineNumber != -1)
 
  643         if (result.size() && result[result.size() - 1] != 
'\n')
 
  648     return result.trimmed();
 
  690     vector<string> theStack;
 
  691     StackTrace::GetStackTrace(&theStack);
 
  694     for(
unsigned int i = 1; i < theStack.size(); i++) {
 
  695       message += (theStack[i] + 
"\n").c_str();
 
  699     if (theStack.size() != 0) {
 
  719         result = 
"USER ERROR";
 
  722         result = 
"PROGRAMMER ERROR";
 
  725         result = 
"I/O ERROR";
 
  744       const QString &
string) {
 
  747     if(
string == 
"USER ERROR")
 
  749     else if(
string == 
"PROGRAMMER ERROR")
 
  751     else if(
string == 
"I/O ERROR")
 
  769     char *result = 
new char[whatStr.size() + 1];
 
  770     strncpy(result, whatStr.toLatin1().data(), whatStr.size());
 
  771     result[whatStr.size()] = 
'\0';
 
Pvl toPvl() const 
Returns a PVL object representing the contents of this exception. 
 
static IException createStackTrace()
Returns an IException representing the current stack, excluding this method. 
 
~IException()
The destructor frees memory allocated for the message, filename, and list of previous exceptions...
 
void addGroup(const Isis::PvlGroup &group)
Add a group to the object. 
 
void append(const IException &exceptionSource)
Appends the given exception (and its list of previous exceptions) to this exception's causational exc...
 
ErrorType errorType() const 
Returns the source of the error for this exception. 
 
QString toString(bool boolToConvert)
Global function to convert a boolean to a string. 
 
This error is for when a programmer made an API call that was illegal. 
 
A type of error that occurred when performing an actual I/O operation. 
 
static QString Name()
Returns the name of the application. 
 
const char * what() const 
Returns a string representation of this exception in its current state. 
 
int m_lineNumber
The line in the source code file that threw this exception. 
 
ErrorType m_errorType
This exception's error source. 
 
Contains multiple PvlContainers. 
 
IException & operator=(const IException &rhs)
Assign the values of rhs to this instance. 
 
void print() const 
Prints a string representation of this exception to stderr. 
 
A type of error that could only have occurred due to a mistake on the user's part (e...
 
A single keyword-value pair. 
 
A type of error that cannot be classified as any of the other error types. 
 
char * buildWhat() const 
Returns a C string containing a string representation of this exception. 
 
IException()
The default constructor creates an IException instance with no message, previous exceptions, or file info. 
 
Container for cube-like labels. 
 
void swap(IException &other)
Swaps the values of this instance's member data with other. 
 
QString * m_fileName
The source code file that threw this exception. 
 
int groups() const 
Returns the number of groups contained. 
 
ErrorType
Contains a set of exception error types. 
 
static QString errorTypeToString(ErrorType t)
Returns the source of the error in string format for the given ErrorType. 
 
QString toString() const 
Returns a string representation of this exception. 
 
static ErrorType stringToErrorType(const QString &s)
Given a string, returns the error type associated with it. 
 
QString * m_message
The message associated with this exception. 
 
void deleteEmptyMemberStrings()
This is a helper method for the constructors. 
 
char * m_what
This is used to store the return value of what() in a way that guarantees the returned data will not ...
 
QList< IException > * m_previousExceptions
A list of exceptions that caused this exception. 
 
bool hasKeyword(const QString &name) const 
Check to see if a keyword exists.