Class org.as2lib.env.except.ThrowableStringifier

org.as2lib.core.BasicClass
   +--org.as2lib.env.except.ThrowableStringifier

Implemented Interfaces

Stringifier

Description

ThrowableStringifier stringifies instances of type Throwable.

Method Index

new ThrowableStringifier()

execute(), stringifyStackTrace()

Inherited from BasicClass

toString()

Constructor Detail

ThrowableStringifier

public function ThrowableStringifier(showStackTrace:Boolean, showCause:Boolean)

Constructs a new ThrowableStringifier instance.

You can switch different parts of the string representation on or off using the declared arguments.

The stack trace and the cause are be default shown. That means if you want them to be contained in the resulting string representation you do not have to specify any arguments.

The settings apply only to the throwable to stringify. That means they do not apply for its cause. The cause is responsible for stringifying itself.

Parameters

showStackTracedetermines whether the string representation contains the stack trace
showCausedetermines whether the string representation contains the cause

Method Detail

execute

public function execute(target):String

Returns a string representation of the passed-in Throwable instance.

Depending on the settings you made on instantiation the stack trace and cause is contained in the resulting string or not.

Note that the cause is stringified by its own stringifier. That means the setting show stack trace and show cause settings apply only for this throwable and not for its causes. The cause is responsible for stringifying itself.

The throwable elements are also responsible for stringifying themselves.

The string representation is composed as follows:

   theFullQualifiedNameOfTheThrowable: theMessage
     at theStringRepresentationOfTheStackTraceElement
     ..
   Caused by: theStringRepresentationOfTheCause
 

Here is how a real string representation could look like:

   org.as2lib.data.holder.IllegalLengthException: The argument length '-2' is not allowed to be negative.
     at org.as2lib.data.holder.MyDataHolder.setMaximumLength(Number)
   Caused by: org.as2lib.data.math.IllegalNumberException: The argument number '-2' is not allowed in a range from 0 to ∞.
     at org.as2lib.data.math.Range.setNumber(Number)
 

Parameters

targetthe Throwable to stringify

Return

the string representation of the passed-in target throwable

Specified By

execute() in org.as2lib.util.Stringifier

stringifyStackTrace

public function stringifyStackTrace(stackTrace:Array):String

Stringifies the passed-in stackTrace array that contains StackTraceElement instances.

The individual StackTraceElement instances are responsible for stringifying themselves.

The resulting string representation is composed as follows:

     at theStringRepresentationOfTheFirstStackTraceElement
     at theStringRepresentationOfTheSecondStackTraceElement
     ..
 

A real string representation could look like this:

     at org.as2lib.data.math.Range.setNumber(Number)
     at org.as2lib.data.holder.MyDataHolder.setMaximumLength(Number)
     at com.simonwacker.MyApplication.initialize()
 

Parameters

stackTracethe stack trace to stringify

Return

the string representation of the passed-in stackTrace