????
+--Error
+--org.as2lib.env.except.AbstractThrowable
+--org.as2lib.env.except.Exception
Throwable
Exception
is a default implementation of the Throwable
interface.
It differs from the FatalException class in that it marks the
throwable as not-fatal. That means it differs from a FatalException
in
its fatality.
It also uses the Logger.error
method to log itself, while the
FatalException
class uses the Logger.fatal
method.
Example:
The above example is supposed to be in a method, that has been declared on a
class.
Note that you normally do not throw instances of this class directly. It is
better to sub-class it, that means to create a custom exception, that explains
its purpose more closely by its name, and throw this exception instead.
If you are building a framework that shall be reused it is also helpful to
built a exception inheritance hierarchy, where you have one base class. You can
then categorize different exceptions by their inheritance hierarchy. This
enables you to catch all exceptions from your whole framework or only from
specific parts of your framework.
For a detailed explanation on how to use throwables, what this exception
framework offers you and how to work appropriately with throwables take a look
at the class documentation of the
throw new Exception("This is a detailed message that explains the problem.", this, arguments);
Throwable
interface.
new Exception()
addStackTraceElement(), getCause(), getMessage(), getStackTrace(), getStringifier(), initCause(), setStringifier()
public function Exception(message:String, thrower, args:Array)
Constructs a new Exception
instance.
All arguments are allowed to be null
or undefined
. But if one
is, the string representation returned by the toString
method will not
be complete.
The args
array should be the internal arguments array of the method
that throws the throwable. The internal arguments array exists in every method
and contains its parameters, the callee method and the caller method. You can
refernce it in every method using the name "arguments"
.
message | the message that describes the problem in detail |
thrower | the object that declares the method that throws this exception |
args | the arguments of the throwing method |
public function toString():String
Returns the string representation of this exception.
If you do not call this method out of another method, it also executes
the error
method on the logger returned by the
AbstractThrowable.getLogger method passing this
because it
thinks that the virtual machine called this method.
The string representation is obtained via the invocation of the AbstractThrowable.doToString method that uses the stringifier returned by the static AbstractThrowable.getStringifier method.
If you want to change the appearance of all exceptions set a new stringifier via the static AbstractThrowable.setStringifier method.
If you only want to change the string representation of one exception and
its sub-classes overwrite the doToString
method in your custom
exception.
Do not overwrite this method because you will lose the functionality that invokes the logger when the exception has not been caught and has now reached the final 'level', the virtual machine, that invokes this method.
the string representation of this fatal exception