The general exception class.
More...
#include <base/Exception.h>
Inherited by AmbiguousRegistration, ArgumentException, CacheException, CastException, ConcurrencyException, Construct, ContainerException, DateException, Destruct, DOMException, DOMImplementation::EventException, ExpressionException, extension::RegistryException, FileSystemException, Group::GroupException, IncompatibleOperands, InvalidException, InvalidFormat, IOException, JSONException, LinkerException, LockException, Matrix< TYPE >::MatrixException, MultibyteException, NotImplemented, NotSupported, ObjectModelException, OpenCLException, OpenGLException, OutOfBounds, OutOfDomain, OutOfRange, Overflow, ParseException, Process::ProcessException, RegExp::RegExpException, ResourceException, RMIException, SAXException, SecurityException, SingletonException, StringException, Thread::ThreadException, ThreadKeyImpl::ThreadKeyException, ThreadPool::ThreadPoolException, TransformerException, Trustee::TrusteeException, Underflow, UnexpectedFailure, User::UserException, UserInterfaceException, Vector< TYPE >::VectorException, WebAssembly::WebAssemblyException, and YAMLException.
|
enum | DumpOnThrow { DUMP_ON_THROW_NO = 0,
DUMP_ON_THROW_EXCEPTION,
DUMP_ON_THROW_STACK
} |
|
typedef void(* | ExceptionHandler) (const Exception *exception) |
|
|
static constexpr bool | SUPPORTS_EXCEPTIONS = true |
|
The general exception class.
This is the base class of all exceptions supported by the framework. Normally exceptions do not raise exceptions themselves. It is highly advised against raising objects which are not specializations of Exception. Exceptions allow the developer to handle 'rare' conditions at runtime in a safe manner. An exception doesn't have to be indicating an error but normally does. Uncaught exceptions will terminate the executing context with an error (in the case of the main context the entire application is terminated).
- Version
- 1.2
- Examples
- testsuite/Array.cpp, testsuite/digest.cpp, testsuite/ftp.cpp, testsuite/IEEE1394.cpp, and testsuite/ls.cpp.
◆ ExceptionHandler
typedef void(* Exception::ExceptionHandler) (const Exception *exception) |
◆ Exception() [1/6]
Initializes the exception object without an associated message and type identity.
◆ Exception() [2/6]
Exception::Exception |
( |
const char * |
message | ) |
|
|
noexcept |
Initializes the exception object.
- Parameters
-
message | An NULL-terminated string (ASCII). |
◆ Exception() [3/6]
Exception::Exception |
( |
const Type & |
type | ) |
|
|
noexcept |
Initializes the exception object without an associated message.
- Parameters
-
type | The identity of the type. |
◆ Exception() [4/6]
Exception::Exception |
( |
const char * |
message, |
|
|
const Type & |
type |
|
) |
| |
|
noexcept |
Initializes the exception object.
void myMethod()
{
if (!condition) {
}
...
}
- Parameters
-
message | An NULL-terminated string (ASCII). |
type | The identity of the type. |
◆ Exception() [5/6]
Exception::Exception |
( |
const Exception & |
copy | ) |
|
|
noexcept |
Copy constructor.
- Parameters
-
exception | The exception object to be copied. |
◆ Exception() [6/6]
Move constructor.
- Parameters
-
exception | The exception object to be moved. |
◆ ~Exception()
virtual Exception::~Exception |
( |
| ) |
|
|
virtualnoexcept |
Destroys exception object.
◆ getCause()
unsigned int Exception::getCause |
( |
| ) |
const |
|
inlinenoexcept |
Returns the associated cause. 0 indicates an unspecified cause.
◆ getDumpExceptions()
static bool Exception::getDumpExceptions |
( |
| ) |
|
|
inlinestaticnoexcept |
Returns true if stack traces for new exceptions are printed.
◆ getError()
unsigned int Exception::getError |
( |
| ) |
const |
|
inlinenoexcept |
Returns the associated native error code. 0 if no error.
◆ getExceptionType()
static Type Exception::getExceptionType |
( |
| ) |
|
|
staticnoexcept |
Returns the type of the caught exception.
- Returns
- An uninitialized type is returned if no exception has been caught or this method isn't supported.
◆ getHTML()
Returns HTML information.
◆ getMessage()
const char* Exception::getMessage |
( |
| ) |
const |
|
inlinenoexcept |
◆ getPendingExceptions()
static unsigned int Exception::getPendingExceptions |
( |
| ) |
|
|
staticnoexcept |
Returns the number of currently pending/unhandled exceptions.
◆ getStackTrace()
Returns the stack trace for the last constructed exception. Avoid constructing exception that are not thrown as these will hide the true exception.
- Returns
- Can return nullptr if exception is unknown. Do NOT keep the pointers outside scope.
◆ getStdExceptionName()
static const char* Exception::getStdExceptionName |
( |
const std::exception & |
e | ) |
|
|
staticnoexcept |
Returns description for well-known Std C++ exceptions.
◆ getThisType()
virtual Type Exception::getThisType |
( |
| ) |
const |
|
virtualnoexcept |
Returns the type of the exception.
◆ getType()
const Type& Exception::getType |
( |
| ) |
const |
|
inlinenoexcept |
Returns the identity of the type which raised the exception.
◆ hasPendingException()
static bool Exception::hasPendingException |
( |
| ) |
|
|
staticnoexcept |
Returns true if an exception is pending.
◆ isCommonException()
virtual bool Exception::isCommonException |
( |
| ) |
const |
|
virtualnoexcept |
◆ isUnwinding()
static bool Exception::isUnwinding |
( |
| ) |
|
|
staticnoexcept |
Returns true if the stack is currently being unwinded due to a raised exception.
- See also
- getExceptionType
- Returns
- False if not supported.
◆ onThrow()
static void Exception::onThrow |
( |
const Exception & |
exception | ) |
|
|
staticnoexcept |
◆ rethrow()
static void Exception::rethrow |
( |
| ) |
|
|
static |
Rethrows exception. Throws Exception if there is no current exception.
◆ setCause()
void Exception::setCause |
( |
unsigned int |
cause | ) |
|
|
inlinenoexcept |
Sets the cause. 0 indicates an unspecified cause.
◆ setDumpExceptions()
static void Exception::setDumpExceptions |
( |
bool |
_dumpExceptions | ) |
|
|
inlinestaticnoexcept |
Enables printing of stack traces when exceptions are constructed.
◆ setDumpOnThrow()
static void Exception::setDumpOnThrow |
( |
DumpOnThrow |
dumpOnThrow | ) |
|
|
staticnoexcept |
Sets whether or not to dump expection on throw.
◆ setError()
void Exception::setError |
( |
unsigned int |
error | ) |
|
|
inlinenoexcept |
Sets the native error code. 0 indicates no error.
◆ setExceptionHandler()
◆ setMessage() [1/2]
void Exception::setMessage |
( |
const char * |
message | ) |
|
|
inlinenoexcept |
Associates the exception with the specified message.
◆ setMessage() [2/2]
template<decltype(sizeof(void *)) SIZE>
void Exception::setMessage |
( |
const char(&) |
_message[SIZE] | ) |
|
|
inlinenoexcept |
Associates the exception with the specified message.
◆ setType()
void Exception::setType |
( |
const Type & |
type | ) |
|
|
inlinenoexcept |
Sets the identity of the type which raised the exception.