|
Isis 3.0 Object Programmers' Reference |
Home |
#include <IException.h>


Public Types | |
| enum | ErrorType { Unknown = 1, User, Programmer, Io } |
Contains a set of exception error types. More... | |
Public Member Functions | |
| IException () | |
| The default constructor creates an IException instance with no message, previous exceptions, or file info. | |
| IException (ErrorType type, const char *message, const char *fileName, int lineNumber) | |
| This version of the constructor creates an IException instance with the given error type, message, and file info. | |
| IException (ErrorType type, const std::string &message, const char *fileName, int lineNumber) | |
| This version of the constructor creates an IException instance with the given error type, message, and file info. | |
| IException (ErrorType type, const QString &message, const char *fileName, int lineNumber) | |
| This version of the constructor creates an IException instance with the given error type, message, and file info. | |
| IException (const IException &caughtException, ErrorType newExceptionType, const char *message, const char *fileName, int lineNumber) | |
| This version of the constructor creates an IException instance with the given error type, message, file info. | |
| IException (const IException &caughtException, ErrorType newExceptionType, const std::string &message, const char *fileName, int lineNumber) | |
| This version of the constructor creates an IException instance with the given error type, message, file info. | |
| IException (const IException &caughtException, ErrorType newExceptionType, const QString &message, const char *fileName, int lineNumber) | |
| This version of the constructor creates an IException instance with the given error type, message, file info. | |
| IException (const IException &other) | |
| The copy constructor creates a copy of the given exception. | |
| ~IException () throw () | |
| The destructor frees memory allocated for the message, filename, and list of previous exceptions. | |
| const char * | what () const throw () |
| Returns a string representation of this exception in its current state. | |
| void | append (const IException &exceptionSource) |
| Appends the given exception (and its list of previous exceptions) to this exception's causational exception list. | |
| ErrorType | errorType () const |
| Returns the source of the error for this exception. | |
| void | print () const |
| Prints a string representation of this exception to stderr. | |
| void | print (bool printFileInfo) const |
| Prints a string representation of this exception to stderr, including file info if specified. | |
| Pvl | toPvl () const |
| Returns a PVL object representing the contents of this exception. | |
| QString | toString () const |
| Returns a string representation of this exception. | |
| QString | toString (bool printFileInfo) const |
| Returns a string representation of this exception, including file info if specified. | |
| void | swap (IException &other) |
| Swaps the values of this instance's member data with other. | |
| IException & | operator= (const IException &rhs) |
| Assign the values of rhs to this instance. | |
Private Member Functions | |
| char * | buildWhat () const |
| Returns a C string containing a string representation of this exception. | |
| void | deleteEmptyMemberStrings () |
| This is a helper method for the constructors. | |
Static Private Member Functions | |
| static IException | createStackTrace () |
| Returns an IException representing the current stack, excluding this method. | |
| static QString | errorTypeToString (ErrorType t) |
| Returns the source of the error in string format for the given ErrorType. | |
| static ErrorType | stringToErrorType (const QString &s) |
| Given a string, returns the error type associated with it. | |
Private Attributes | |
| char * | m_what |
| This is used to store the return value of what() in a way that guarantees the returned data will not be deleted as long as this instance is unmodified. | |
| ErrorType | m_errorType |
| This exception's error source. | |
| QString * | m_message |
| The message associated with this exception. | |
| QString * | m_fileName |
| The source code file that threw this exception. | |
| int | m_lineNumber |
| The line in the source code file that threw this exception. | |
| QList< IException > * | m_previousExceptions |
| A list of exceptions that caused this exception. | |
Isis exception class.
This class represents a general Isis exception. It contains an enumeration for what type of error the exception represents, and can optionally track what exceptions caused the current exception. This class also provides access to string and PVL representations of the exception.
Instances of this class should be thrown by value and caught be reference. Please see the constructor documentation for code examples on how to create and throw exceptions.
All methods in this class are re-entrant.
For internal use only.
Definition at line 99 of file IException.h.
Contains a set of exception error types.
These types indicate the source of the error. For example, if the error type is User, this indicates that the exception was thrown due to something the user did wrong, such as provide a cube with no SPICE data to an application that needed a spiceinit'd cube as input.
Definition at line 119 of file IException.h.
| Isis::IException::IException | ( | ) |
The default constructor creates an IException instance with no message, previous exceptions, or file info.
The exception error type is Unknown.
This default constructor exists so that IException instances can be stored in Qt containers such as lists. This is also used for cancelling a program run.
throw IException();
Definition at line 56 of file IException.cpp.
References buildWhat(), m_errorType, m_fileName, m_lineNumber, m_message, m_previousExceptions, m_what, and Unknown.
Referenced by createStackTrace().
| Isis::IException::IException | ( | ErrorType | type, | |
| const char * | message, | |||
| const char * | fileName, | |||
| int | lineNumber | |||
| ) |
This version of the constructor creates an IException instance with the given error type, message, and file info.
The IException instance will not have any previous exceptions associated with it initially (i.e. no exception caused this one to be thrown).
throw IException(IException::Unknown, "While doing an important process, we could not do ... " "because the data [" ... "] is invalid", _FILEINFO_);
| type | the source of the error that this exception represents | |
| message | the string message containing details about the error, which may be displayed to the user | |
| fileName | the filename of the file that this exception was thrown in | |
| lineNumber | the line in the source code file that threw this exception |
Definition at line 126 of file IException.cpp.
References buildWhat(), deleteEmptyMemberStrings(), m_errorType, m_fileName, m_lineNumber, m_message, m_previousExceptions, m_what, and trimmed.
| Isis::IException::IException | ( | ErrorType | type, | |
| const std::string & | message, | |||
| const char * | fileName, | |||
| int | lineNumber | |||
| ) |
This version of the constructor creates an IException instance with the given error type, message, and file info.
The IException instance will not have any previous exceptions associated with it initially (i.e. no exception caused this one to be thrown). The QString version of this constructor is preferred over this one.
std::string message = "While doing an important process, we could not do .. " "because the data [" ... "] is invalid"; throw IException(IException::Unknown, message, _FILEINFO_);
| type | the source of the error that this exception represents | |
| message | the string message containing details about the error, which may be displayed to the user | |
| fileName | the filename of the file that this exception was thrown in | |
| lineNumber | the line in the source code file that threw this exception |
Definition at line 164 of file IException.cpp.
References buildWhat(), deleteEmptyMemberStrings(), m_errorType, m_fileName, m_lineNumber, m_message, m_previousExceptions, m_what, and trimmed.
| Isis::IException::IException | ( | ErrorType | type, | |
| const QString & | message, | |||
| const char * | fileName, | |||
| int | lineNumber | |||
| ) |
This version of the constructor creates an IException instance with the given error type, message, and file info.
The IException instance will not have any previous exceptions associated with it initially (i.e. no exception caused this one to be thrown).
throw IException(IException::Unknown, tr("While doing an important process, we could not do ... " "because the data [%1] is invalid").arg(...), _FILEINFO_);
| type | the source of the error that this exception represents | |
| message | the string message containing details about the error, which may be displayed to the user | |
| fileName | the filename of the file that this exception was thrown in | |
| lineNumber | the line in the source code file that threw this exception |
Definition at line 88 of file IException.cpp.
References buildWhat(), deleteEmptyMemberStrings(), m_errorType, m_fileName, m_lineNumber, m_message, m_previousExceptions, m_what, and trimmed.
| Isis::IException::IException | ( | const IException & | caughtException, | |
| ErrorType | type, | |||
| const char * | message, | |||
| const char * | fileName, | |||
| int | lineNumber | |||
| ) |
This version of the constructor creates an IException instance with the given error type, message, file info.
The IException instance will append the given exception to its list of previous exceptions (as well as any previous exceptions associated with the caught exception). Use this constructor when you want to rethrow a new exception after catching an exception and preserve the previous message(s).
try { ... } catch (IException &e) { throw IException(e, IException::Unknown, "While doing an important process, we could not do " "... ", _FILEINFO_); }
| caughtException | the previous exception that caused this exception to be thrown | |
| type | the source of the error that this exception represents | |
| message | the string message containing details about the error, which may be displayed to the user | |
| fileName | the filename of the file that this exception was thrown in | |
| lineNumber | the line in the source code file that threw this exception |
Definition at line 212 of file IException.cpp.
References append(), deleteEmptyMemberStrings(), m_errorType, m_fileName, m_lineNumber, m_message, m_previousExceptions, m_what, and trimmed.
| Isis::IException::IException | ( | const IException & | caughtException, | |
| ErrorType | type, | |||
| const std::string & | message, | |||
| const char * | fileName, | |||
| int | lineNumber | |||
| ) |
This version of the constructor creates an IException instance with the given error type, message, file info.
The IException instance will append the given exception to its list of previous exceptions (as well as any previous exceptions associated with the caught exception). Use this constructor when you want to rethrow a new exception after catching an exception and preserve the previous message(s). The QString version of this constructor is preferred over this one.
try { ... } catch (IException &e) { string message = "While doing an important process, we could not do " "... "; throw IException(e, IException::Unknown, message, _FILEINFO_); }
| caughtException | the previous exception that caused this exception to be thrown | |
| type | the source of the error that this exception represents | |
| message | the string message containing details about the error, which may be displayed to the user | |
| fileName | the filename of the file that this exception was thrown in | |
| lineNumber | the line in the source code file that threw this exception |
Definition at line 260 of file IException.cpp.
References append(), deleteEmptyMemberStrings(), m_errorType, m_fileName, m_lineNumber, m_message, m_previousExceptions, m_what, and trimmed.
| Isis::IException::IException | ( | const IException & | caughtException, | |
| ErrorType | type, | |||
| const QString & | message, | |||
| const char * | fileName, | |||
| int | lineNumber | |||
| ) |
This version of the constructor creates an IException instance with the given error type, message, file info.
The IException instance will append the given exception to its list of previous exceptions (as well as any previous exceptions associated with the caught exception). Use this constructor when you want to rethrow a new exception after catching an exception and preserve the previous message(s).
try { ... } catch (IException &e) { QString message = "While doing an important process, we could not do " "... "; throw IException(e, IException::Unknown, message, _FILEINFO_); }
| caughtException | the previous exception that caused this exception to be thrown | |
| type | the source of the error that this exception represents | |
| message | the string message containing details about the error, which may be displayed to the user | |
| fileName | the filename of the file that this exception was thrown in | |
| lineNumber | the line in the source code file that threw this exception |
Definition at line 307 of file IException.cpp.
References append(), deleteEmptyMemberStrings(), m_errorType, m_fileName, m_lineNumber, m_message, m_previousExceptions, and m_what.
| Isis::IException::IException | ( | const IException & | other | ) |
The copy constructor creates a copy of the given exception.
| other | the exception to copy from |
Definition at line 331 of file IException.cpp.
References m_errorType, m_fileName, m_lineNumber, m_message, m_previousExceptions, and m_what.
| Isis::IException::~IException | ( | ) | throw () |
The destructor frees memory allocated for the message, filename, and list of previous exceptions.
Definition at line 365 of file IException.cpp.
References m_errorType, m_fileName, m_lineNumber, m_message, m_previousExceptions, m_what, and Unknown.
| void Isis::IException::append | ( | const IException & | exceptionSource | ) |
Appends the given exception (and its list of previous exceptions) to this exception's causational exception list.
The passed in exception is the cause of this exception. Exceptions should be appended in the original order that they were thrown - earlier first.
This method causes the results of what() to be rebuilt, invalidating any previous results.
try { ... } catch (IException &error1) { try { ... } catch (IException &error2) { IException finalError(IException::Unknown, "...", _FILEINFO_); finalError.append(error1); finalError.append(error2); throw finalError; } }
| exceptionSource | the exception that should be added to the list of previous exceptions |
Definition at line 425 of file IException.cpp.
References buildWhat(), m_previousExceptions, and m_what.
Referenced by Isis::ProjectionFactory::CreateForCube(), IException(), Isis::UniversalGroundMap::Init(), Isis::ImagePolygon::initCube(), Isis::IssNACamera::IssNACamera(), Isis::Chip::Load(), Isis::ProgramLauncher::ProcessIsisMessageFromChild(), and Isis::ProgramLauncher::RunIsisProgram().
| char * Isis::IException::buildWhat | ( | ) | const [private] |
Returns a C string containing a string representation of this exception.
This method should be called any time the current exception is modified (e.g. appending an exception to the previous exceptions list, etc.) in order to keep m_what synched with the current state of the exception.
Definition at line 766 of file IException.cpp.
References toString().
Referenced by append(), and IException().
| IException Isis::IException::createStackTrace | ( | ) | [static, private] |
Returns an IException representing the current stack, excluding this method.
Definition at line 689 of file IException.cpp.
References IException(), and Unknown.
| void Isis::IException::deleteEmptyMemberStrings | ( | ) | [private] |
This is a helper method for the constructors.
When the message or source code file name are empty strings, we want our members to be NULL instead of empty IStrings.
Definition at line 782 of file IException.cpp.
References m_fileName, and m_message.
Referenced by IException().
| IException::ErrorType Isis::IException::errorType | ( | ) | const |
Returns the source of the error for this exception.
Definition at line 446 of file IException.cpp.
References m_errorType.
Referenced by Isis::Application::Application(), Isis::NumericalApproximation::BackwardFirstDifference(), Isis::NumericalApproximation::BackwardSecondDifference(), Isis::NumericalApproximation::BoolesRule(), Isis::NumericalApproximation::CenterFirstDifference(), Isis::NumericalApproximation::CenterSecondDifference(), Isis::NumericalApproximation::ComputeCubicClamped(), Isis::NumericalApproximation::ComputeGsl(), Isis::NumericalApproximation::CubicClampedSecondDerivatives(), Isis::NumericalApproximation::DomainMaximum(), Isis::NumericalApproximation::DomainMinimum(), Isis::NumericalApproximation::Evaluate(), Isis::NumericalApproximation::EvaluateCubicNeighborhood(), Isis::NumericalApproximation::EvaluateForIntegration(), Isis::NumericalApproximation::ForwardFirstDifference(), Isis::NumericalApproximation::ForwardSecondDifference(), Isis::Application::FunctionError(), Isis::NumericalApproximation::GslFirstDerivative(), Isis::NumericalApproximation::GslIntegral(), Isis::NumericalApproximation::GslSecondDerivative(), Isis::NumericalApproximation::Init(), Isis::NumericalApproximation::InsideDomain(), Isis::NumericalApproximation::MinPoints(), Isis::NumericalApproximation::Name(), Isis::NumericalApproximation::NumericalApproximation(), Isis::NumericalApproximation::operator=(), Isis::NumericalAtmosApprox::OutrFunc2Bint(), Isis::NumericalApproximation::RefineExtendedTrap(), Isis::NumericalAtmosApprox::RefineExtendedTrap(), Isis::NumericalApproximation::Reset(), Isis::NumericalApproximation::RombergsMethod(), Isis::NumericalAtmosApprox::RombergsMethod(), Isis::NumericalApproximation::SetInterpType(), Isis::NumericalApproximation::Simpsons3PointRule(), Isis::NumericalApproximation::Simpsons4PointRule(), and Isis::NumericalApproximation::TrapezoidalRule().
| QString Isis::IException::errorTypeToString | ( | ErrorType | type | ) | [static, private] |
Returns the source of the error in string format for the given ErrorType.
| type | the ErrorType enum to convert to a string |
Definition at line 714 of file IException.cpp.
References Io, Programmer, Unknown, and User.
Referenced by toPvl(), and toString().
| IException & Isis::IException::operator= | ( | const IException & | rhs | ) |
Assign the values of rhs to this instance.
This is a deep copy and is exception-safe.
| rhs | the IException on the right-hand side of the equals operator |
Definition at line 675 of file IException.cpp.
References swap().
| void Isis::IException::print | ( | bool | printFileInfo | ) | const |
Prints a string representation of this exception to stderr, including file info if specified.
The printed exception will be either PVL-formatted or formatted as plain sentences according to the user's preferences file.
| printFileInfo | whether or not to include file info in the printed version of this exception. This ignores the option set in the user's preferences file regarding file info. |
Definition at line 477 of file IException.cpp.
References toString().
| void Isis::IException::print | ( | ) | const |
Prints a string representation of this exception to stderr.
File info (i.e. filename and line number) are only printed if the user has that option enabled in their preferences file. The printed exception will be either PVL-formatted or formatted as plain sentences according to the user's preferences file.
This should be the preferred method call in unit tests when testing exceptions thrown by your class.
Definition at line 461 of file IException.cpp.
References toString().
Referenced by Isis::Application::Application(), Isis::ImagePolygon::Create(), Isis::MosaicSceneItem::drawImage(), Isis::CissLabels::Init(), Isis::MosaicController::ProjectToDisplayFunctor::operator()(), Isis::MosaicController::FileNameToDisplayFunctor::operator()(), Isis::MosaicSceneWidget::reprojectItems(), Isis::Pipeline::Run(), and Isis::VoyagerCamera::VoyagerCamera().
| IException::ErrorType Isis::IException::stringToErrorType | ( | const QString & | string | ) | [static, private] |
Given a string, returns the error type associated with it.
| string | the string to convert into the appropriate ErrorType |
Definition at line 743 of file IException.cpp.
References Io, Programmer, Unknown, and User.
| void Isis::IException::swap | ( | IException & | other | ) |
Swaps the values of this instance's member data with other.
This method is exception-safe.
| other | the exception to swap member data with |
Definition at line 658 of file IException.cpp.
References m_errorType, m_fileName, m_lineNumber, m_message, m_previousExceptions, and m_what.
Referenced by operator=().
| Pvl Isis::IException::toPvl | ( | ) | const |
Returns a PVL object representing the contents of this exception.
File info is included unless there is no filename or line number associated with an exception, regardless of the user's preferences file.
Definition at line 491 of file IException.cpp.
References Isis::PvlObject::AddGroup(), errors, errorTypeToString(), m_previousExceptions, Isis::Application::Name(), Isis::toString(), and Unknown.
Referenced by Isis::Application::FunctionError(), and toString().
| QString Isis::IException::toString | ( | bool | includeFileInfo | ) | const |
Returns a string representation of this exception, including file info if specified.
The string representation of the exception will be either PVL-formatted or formatted as plain sentences according to the user's preferences file.
| includeFileInfo | whether or not to include file info in the string representation of this exception. This ignores the option set in the user's preferences file regarding file info. |
Definition at line 580 of file IException.cpp.
References errors, errorTypeToString(), Isis::PvlObject::Groups(), Isis::PvlContainer::HasKeyword(), m_previousExceptions, toPvl(), toString(), and Unknown.
| QString Isis::IException::toString | ( | ) | const |
Returns a string representation of this exception.
File info (i.e. filename and line number) are only included if the user has that option enabled in their preferences file. The string representation of the exception will be either PVL-formatted or formatted as plain sentences according to the user's preferences file.
Definition at line 553 of file IException.cpp.
References Isis::PvlContainer::HasKeyword().
Referenced by Isis::Gruen::algorithm(), buildWhat(), Isis::ControlPointEdit::ControlPointEdit(), Isis::MosaicSceneWidget::createReferenceFootprint(), Isis::Gruen::errorAnalysis(), Isis::Application::FunctionError(), Isis::ChipViewport::geomChip(), Isis::Application::GuiReportError(), Isis::ProjectionConfigDialog::loadFromFile(), Isis::MosaicControlNetTool::loadNetwork(), Isis::StereoTool::measureSaved(), Isis::MatchTool::mouseButtonRelease(), Isis::ChipViewport::nogeomChip(), print(), Isis::ControlPointEdit::registerPoint(), Isis::ChipViewport::reloadChip(), Isis::ChipViewport::rotateChip(), Isis::PvlEditDialog::saveTextEdit(), Isis::MatchTool::selectLeftMeasure(), Isis::MatchTool::selectRightMeasure(), Isis::StereoTool::setFiles(), Isis::ControlPointEdit::setGeom(), Isis::ControlPointEdit::setRightMeasure(), Isis::ZoomTool::setScale(), Isis::ControlPointEdit::setTemplateFile(), Isis::Gui::StartProcess(), toString(), Isis::ControlPointEdit::updateRightGeom(), Isis::StereoTool::viewTemplateFile(), Isis::MatchTool::viewTemplateFile(), and Isis::MatchTool::writeTemplateFile().
| const char * Isis::IException::what | ( | ) | const throw () |
Returns a string representation of this exception in its current state.
The results of this method are guaranteed to be valid until the instance is modified.
Definition at line 391 of file IException.cpp.
References m_what.
Referenced by Isis::ImagePolygon::Fix360Poly(), Isis::ImageOverlapSet::HandleError(), Isis::QIsisApplication::notify(), Isis::ProjectionConfigDialog::refreshWidgetStates(), Isis::MatchTool::saveAsNet(), and Isis::MatchTool::saveNet().
ErrorType Isis::IException::m_errorType [private] |
This exception's error source.
If the source cannot be positively identified, then this should be set to Unknown.
Definition at line 227 of file IException.h.
Referenced by errorType(), IException(), swap(), and ~IException().
QString* Isis::IException::m_fileName [private] |
The source code file that threw this exception.
Definition at line 238 of file IException.h.
Referenced by deleteEmptyMemberStrings(), IException(), swap(), and ~IException().
int Isis::IException::m_lineNumber [private] |
The line in the source code file that threw this exception.
Definition at line 243 of file IException.h.
Referenced by IException(), swap(), and ~IException().
QString* Isis::IException::m_message [private] |
The message associated with this exception.
This will be NULL if the message is empty (or only contained whitespace).
Definition at line 233 of file IException.h.
Referenced by deleteEmptyMemberStrings(), IException(), swap(), and ~IException().
QList<IException>* Isis::IException::m_previousExceptions [private] |
A list of exceptions that caused this exception.
Definition at line 248 of file IException.h.
Referenced by append(), IException(), swap(), toPvl(), toString(), and ~IException().
char* Isis::IException::m_what [private] |
This is used to store the return value of what() in a way that guarantees the returned data will not be deleted as long as this instance is unmodified.
Any changes to the current exception will reallocate this and invalidate old values of what().
Definition at line 221 of file IException.h.
Referenced by append(), IException(), swap(), what(), and ~IException().