Represents an exception in the exception handling system. More...
Data Fields | |
const char * | name |
The name of this exception. | |
char | message [E4C_EXCEPTION_MESSAGE_SIZE] |
The message of this exception. | |
const e4c_exception * | super |
The supertype of this exception. | |
const char * | file |
The path of the source code file from which the exception was thrown. | |
int | line |
The number of line from which the exception was thrown. | |
const char * | function |
The function from which the exception was thrown. | |
int | error_number |
The value of errno at the time the exception was thrown. | |
const e4c_exception * | type |
The class of this exception. | |
const e4c_exception * | cause |
The cause of this exception. |
Represents an exception in the exception handling system.
Exceptions are a means of breaking out of the normal flow of control of a code block in order to handle errors or other exceptional conditions. An exception should be thrown at the point where the error is detected; it may be handled by the surrounding code block or by any code block that directly or indirectly invoked the code block where the error occurred.
The types of the exceptions a program will use are defined through the macro E4C_DEFINE_EXCEPTION
:
E4C_DEFINE_EXCEPTION(StackException, "Stack overflow", RuntimeException); E4C_DEFINE_EXCEPTION(StackOverflowException, "Stack overflow", StackException); E4C_DEFINE_EXCEPTION(StackUnderflowException, "Stack underflow", StackException);
When defining types of exceptions, they are given a name, a default message and a supertype to organize them into a pseudo-hierarchy. These can be considered as the compile-time attributes of a exception.
However, exceptions provide further information regarding the exceptional situation at run-time, such as:
errno
at the time the exception was thrown catch
or finally
block catch
block Exceptions are usually defined as global objects. There is a set of predefined exceptions built into the framework, amongst others:
RuntimeException
NotEnoughMemoryException
NullPointerException
FileOpenException
AbortException
ArithmeticException
IllegalInstructionException
BadPointerException
TerminationException
UserInterruptionException
RuntimeException
is the root of the exceptions pseudo-hierarchy. Any exception can be caught by a catch(RuntimeException)
block, except AssertionException
.
The cause of this exception.
The value of errno at the time the exception was thrown.
const char* e4c_exception::file |
The path of the source code file from which the exception was thrown.
const char* e4c_exception::function |
The function from which the exception was thrown.
The number of line from which the exception was thrown.
char e4c_exception::message[E4C_EXCEPTION_MESSAGE_SIZE] |
The message of this exception.
const char* e4c_exception::name |
The name of this exception.
The supertype of this exception.
const e4c_exception* e4c_exception::type |
The class of this exception.