Error class

Error is a wrapper around an Object that represents an error or context around a parent error. Used for chaining error Objects that are related.

Implemented types
Available extensions

Constructors

Error(Object _cause, {Error? parent})

Properties

hashCode int
The hash code for this object.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

chain() Iterable<Error>
An iterator of the chain of source errors. Starting at the this.
clone<E extends Object>({E? cause, Error? parent}) Error
Creates a clone of this Error, cloning all Error, but the causes are not cloned.
downcast<E extends Object>() Result<E>
Attempt to downcast the error object to a concrete type.
downcastUnchecked<E extends Object>() → E
Attempt to downcast the error object to a concrete type without error handling. If the downcast fails, this will throw an exception. This is useful when you know the downcast should always succeed, like when casting to Object for use in a case statement.
isRoot() bool
Is this Error the first error
isType<E extends Object>() bool
Returns true if E is the type held by this error object.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
rootCause() Error
The lowest level cause of this error — this error’s cause’s cause’s cause etc. The root cause is the last error in the iterator produced by chain.
stacktrace() StackTrace?
The stacktrace for this error, if hasStackTrace is set to true, this will not be null.
toString() String
Human readable error representation
override

Operators

operator ==(Object other) bool
The equality operator.
override

Static Properties

displayFormat ErrDisplayFormat
Setting for how errors are converted to strings
getter/setter pair
hasStackTrace bool
If Errors should be captured with a StackTrace.
getter/setter pair
stackTraceDisplayFormat StackTraceDisplayFormat
How to display StackTraces. Requires hasStackTrace = true
getter/setter pair
stackTraceDisplayModifier StackTrace Function(StackTrace)
Modifies the stacktrace during display. Useful for adjusting number of frames to include during display/logging. Stacktraces that are captured internally through "bail", "context", etc. or directly by calling "Error", are always captured as soon as possible - one stack frame below your calling code. Therefore, if you decide to prune during display, you can comfortably prune 1 off the root and then leave as many other frames as you desire. See also the stack_trace package. Requires hasStackTrace = true
getter/setter pair