Err<T, E> class final

Failed operation result.

const result = Err<int, String>('invalid count');
Inheritance
Available extensions

Constructors

Err(E error)
Creates one failed result.
const

Properties

error → E
Error value.
final
hashCode → int
The hash code for this object.
no setteroverride
isErr → bool
Whether this result is Err.
no setterinherited
isOk → bool
Whether this result is Ok.
no setteroverride
orReject → T

Available on Result<T, Rejection>, provided by the RejectOnFailure extension

The extracted value, or a thrown Rejection.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

and<R>(Result<R, E> other) → Result<R, E>

Available on Result<T, E>, provided by the ResultTransform extension

Returns other when this result succeeded, or this error otherwise.
andThen<R>(Result<R, E> next(T value)) → Result<R, E>

Available on Result<T, E>, provided by the ResultChain extension

Chains another result-producing operation when this result is successful.
err() → Option<E>

Available on Result<T, E>, provided by the ResultQuery extension

The error as Some, or None for an Ok.
expect(String message) → T

Available on Result<T, E>, provided by the ResultQuery extension

Returns the successful value, or throws message for an Err.
expectErr(String message) → E

Available on Result<T, E>, provided by the ResultQuery extension

Returns the error, or throws message for an Ok.
flatten() → Result<T, E>

Available on Result<Result<T, E>, E>, provided by the ResultFlatten extension

Turns Ok(Ok(value)) into Ok(value), and either error into Err.
inspect(void action(T value)) → Result<T, E>

Available on Result<T, E>, provided by the ResultTransform extension

Calls action with a successful value, and returns this result unchanged.
inspectErr(void action(E error)) → Result<T, E>

Available on Result<T, E>, provided by the ResultTransform extension

Calls action with the error, and returns this result unchanged.
isErrAnd(bool predicate(E error)) → bool

Available on Result<T, E>, provided by the ResultQuery extension

Whether the result failed and its error satisfies predicate.
isOkAnd(bool predicate(T value)) → bool

Available on Result<T, E>, provided by the ResultQuery extension

Whether the result succeeded and its value satisfies predicate.
map<R>(R mapper(T value)) → Result<R, E>
Maps a successful value and leaves errors unchanged.
override
mapErr<F>(F mapper(E error)) → Result<T, F>
Maps an error value and leaves successful values unchanged.
override
mapOr<R>(R fallback, R mapper(T value)) → R

Available on Result<T, E>, provided by the ResultTransform extension

Maps a successful value, or returns fallback for an Err.
mapOrElse<R>(R fallback(E error), R mapper(T value)) → R

Available on Result<T, E>, provided by the ResultTransform extension

Maps a successful value, or computes a fallback from the error.
match<R>({required R ok(T value), required R err(E error)}) → R
Pattern matches this result.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
ok() → Option<T>

Available on Result<T, E>, provided by the ResultQuery extension

The successful value as Some, or None for an Err.
or<F>(Result<T, F> other) → Result<T, F>

Available on Result<T, E>, provided by the ResultTransform extension

Returns this result when it succeeded, or other otherwise.
orElse<F>(Result<T, F> next(E error)) → Result<T, F>

Available on Result<T, E>, provided by the ResultChain extension

Chains another result-producing operation when this result failed.
toString() → String
A string representation of this object.
override
transpose() → Option<Result<T, E>>

Available on Result<Option<T>, E>, provided by the ResultTranspose extension

Turns a result of an option into an optional result.
unwrap() → T

Available on Result<T, E>, provided by the ResultQuery extension

Returns the successful value, or throws for an Err.
unwrapErr() → E

Available on Result<T, E>, provided by the ResultQuery extension

Returns the error, or throws for an Ok.
unwrapOr(T fallback) → T

Available on Result<T, E>, provided by the ResultChain extension

Returns the successful value, or fallback when this result failed.
unwrapOrElse(T fallback(E error)) → T

Available on Result<T, E>, provided by the ResultChain extension

Returns the successful value, or computes one from the error.

Operators

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