ErrorOr<T> class abstract

A result type with either a value or an error.

Constructors

ErrorOr.error(Object error)
Create an ErrorOr instance of type _ErrorWrapper given an error.
const
factory
ErrorOr.value(T value)
Create an ErrorOr instance of type _ValueWrapper given a value.
const
factory

Properties

error Object
Return the error Object of _ErrorWrapper or throws ErrorOrTypeError if ErrorOr is not a _ErrorWrapper.
no setter
hasError bool
Returns true if ErrorOr is a _ErrorWrapper.
no setter
hashCode int
The hash code for this object.
no setterinherited
hasValue bool
Returns true if ErrorOr is a _ValueWrapper.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value → T
Return the value T of _ValueWrapper or throws ErrorOrTypeError if ErrorOr is not a _ValueWrapper.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

wrap<T>(FutureOr<T> throwing()) FutureOr<ErrorOr<T>>
Wrap a throwing function in a try/catch and return an ErrorOr with either a value or an error, based on whether an exception was thrown or not.