Class org.as2lib.env.except.AbstractThrowable

????
   +--Error
      +--org.as2lib.env.except.AbstractThrowable

Description

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.

Method Index

addStackTraceElement(), getCause(), getMessage(), getStackTrace(), getStringifier(), initCause(), setStringifier()

Method Detail

getStringifier

static public 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.

Return

the current stringifier

setStringifier

static public 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

throwableStringifierthe stringifier to stringify throwables

addStackTraceElement

public 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

throwerthe object that threw, rethrew or forwarded (let pass) the throwable
methodthe method that threw, rethrew or forwarded (let pass) the throwable
argsthe arguments the method was invoked with when throwing, rethrowing or forwarding (leting pass) the throwable

getStackTrace

public 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.

Return

a stack containing the invoked methods until the throwable was thrown

getCause

public function getCause(Void)

Returns the initialized cause.

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

Return

the initialized cause

initCause

public 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

Return

this throwable itself

Throws

IllegalArgumentExceptionif the passed-in newCause is null or undefined
IllegalStateExceptionif the cause has already been initialized

getMessage

public 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.

Return

the message that describes the problem in detail