Throwable

The base class of all thrown objects.

All thrown objects must inherit from Throwable. Class Exception, which derives from this class, represents the category of thrown objects that are safe to catch and handle. In principle, one should not catch Throwable objects that are not derived from Exception, as they represent unrecoverable runtime errors. Certain runtime guarantees may fail to hold when these errors are thrown, making it unsafe to continue execution after catching them.

Destructor

A destructor is present on this object, but not explicitly documented in the source.

Members

Functions

message
const(char)[] message()

Get the message describing the error.

opApply
int opApply(int delegate(Throwable) dg)

Loop over the chain of Throwables.

refcount
uint refcount()
toString
string toString()

Overrides Object.toString and returns the error message. Internally this forwards to the toString overload that takes a sink delegate.

toString
void toString(void delegate(in char[]) sink)

The Throwable hierarchy uses a toString overload that takes a _sink delegate to avoid GC allocations, which cannot be performed in certain error situations. Override this toString method to customize the error message.

Properties

next
inout(Throwable) next [@property getter]
next
Throwable next [@property setter]

Replace next in chain with tail. Use chainTogether instead if at all possible.

Static functions

chainTogether
Throwable chainTogether(Throwable e1, Throwable e2)

Append e2 to chain of exceptions that starts with e1.

Variables

file
string file;

The file name of the D source code corresponding with where the error was thrown from.

info
TraceInfo info;

The stack trace of where the error happened. This is an opaque object that can either be converted to string, or iterated over with foreach to extract the items in the stack trace (as strings).

infoDeallocator
TraceDeallocator infoDeallocator;

If set, this is used to deallocate the TraceInfo on destruction.

line
size_t line;

The line number of the D source code corresponding with where the error was thrown from.

msg
string msg;

A message describing the error.

Inherited Members

From Object

toString
string toString()

Convert Object to a human readable string.

toHash
size_t toHash()

Compute hash function for Object.

opCmp
int opCmp(Object o)

Compare with another Object obj.

opEquals
bool opEquals(Object o)

Test whether this is equal to o. The default implementation only compares by identity (using the is operator). Generally, overrides and overloads for opEquals should attempt to compare objects by their contents. A class will most likely want to add an overload that takes your specific type as the argument and does the content comparison. Then you can override this and forward it to your specific typed overload with a cast. Remember to check for null on the typed overload.

factory
Object factory(string classname)

Create instance of class specified by the fully qualified name classname. The class must either have no constructors or have a default constructor.

Meta