Access keys

AbstractThrowable

Kind of class: class
Inherits from: Error
Known subclasses:
Author: Simon Wacker
Classpath: org.as2lib.env.except.AbstractThrowable
File last modified: Saturday, 10 September 2005, 19:20:42
AbstractThrowable is an abstract class that contains sourced out
functionalities used by the classes Exception and
FatalException.

It is thought to be an abstract implementation of the Throwable
interface. Because of that sub-classes must implement the Throwable
interface if they are themselves not abstract.

This class extends the Error class. Thus you can use sub-classes of
it as throwable type in catch-blocks in Flex.

See also:

Class methods

getStringifier

static function getStringifier (
Void) : Stringifier
Returns the stringifier to stringify throwables.

The returned stringifier is either the default
ThrowableStringifier if no custom stringifier was set or if the
stringifier was set to null.

Returns:
the current stringifier

setStringifier

static function setStringifier (
throwableStringifier:Stringifier) : Void
Sets the stringifier to stringify throwables.

If throwableStringifier is null the static
getStringifier method will return the default stringifier.

Parameters:
throwableStringifier:
the stringifier to stringify throwables

Instance methods

addStackTraceElement

function addStackTraceElement (
thrower, method:Function, args:Array) : Void
Adds a stack trace element to the stack trace.

The new stack trace element is added to the end of the stack trace.

At some parts in your application you may want to add stack trace elements
manually. This can help you to get a clearer image of what went where wrong and
why. You can use this method to do so.

Parameters:
thrower:
the object that threw, rethrew or forwarded (let pass) the
throwable
method :
the method that threw, rethrew or forwarded (let pass) the
throwable
args :
the arguments the method was invoked with when throwing, rethrowing
or forwarding (leting pass) the throwable

getCause

function getCause (
Void)
Returns the initialized cause.

The cause is the throwable that caused this throwable to be thrown.

Returns:
the initialized cause
See also:

getErrorCode

function getErrorCode (
Void) : String
Returns the initialized error code.

Error codes can be used to obtain localized messages appropriate for users;
while the getMessage method returns messages inteded for developers to
get hands on the exception and fix bugs more easily.
The localized messages can for example be obtained through a global message
source and property files.

Returns:
the error code to obtain an error message for users

getMessage

function getMessage (
Void) : String
Returns the message that describes in detail what went wrong.

The message should be understandable, even for non-programmers. It should
contain detailed information about what went wrong. And maybe also how the user
that sees this message can solve the problem.

If the throwable was thrown for example because of a wrong collaborator or
an illegal string or something similar, provide the string representation of it
in the error message. It is recommended to put these between []-characters.

Returns:
the message that describes the problem in detail

getStackTrace

function getStackTrace (
Void) : Array
Returns an array that contains StackTraceElement instances of the
methods invoked before this throwable was thrown.

The last element is always the one that contains the actual method that
threw the throwable.

The stack trace helps you a lot because it says you where the throwing of
the throwable took place and also what arguments caused the throwing.

The returned stack trace is never null or undefined. If
no stack trace element has been set an empty array is returned.

Returns:
a stack containing the invoked methods until the throwable was thrown

initCause

function initCause (
newCause) : Throwable
Initializes the cause of this throwable.

The cause can only be initialized once. You normally initialize a cause
if you throw a throwable due to the throwing of another throwable. Thereby
you do not lose the information the cause offers.

This method returns this throwable to have an easy way to initialize the
cause. Following is how you could use the cause mechanism.

try {
    myInstance.invokeMethodThatThrowsAThrowable();
} catch (e:org.as2lib.env.except.Throwable) {
    throw new MyThrowable("myMessage", this, arguments).initCause(e);
}
Parameters:
cause:
the throwable that caused the throwing of this throwable
Returns:
this throwable itself
Throws:
IllegalArgumentException if the passed-in
newCause is null or undefined
IllegalStateException if the cause has
already been initialized
See also:

initErrorCode

function initErrorCode (
errorCode:String) : Throwable
Initializes the error code for this throwable.

The initialization works only once. Any further initialization results in an
exception.

Take a look at getErrorCode to see what error codes are good for.

Parameters:
errorCode:
the error code to get localized client messages by
Returns:
this throwable
See also: