Err<T extends Object, E extends Exception> class
Result
Result has two variants: Ok and Err
final Result<String, Exception> result =
switch(result) {
return switch (this) {
Ok(:T value) => value,
Err(:E err) => throw err,
};
}
Err
An Err can be created with an exception
final err1 = Result<String, Exception>.err(Exception('Unexpected'));
final err2 = Err<String, Exception>(Exception('Unexpected'));
Constructors
- Err(E err)
- Err
Properties
Methods
-
map<
U extends Object> (U onOk(T)) → Result< U, E> -
Maps the value from
T
toU
if it is Ok, else, keeps the Err,E
.inherited -
mapErr<
E2 extends Exception> (E2 onErr(E)) → Result< T, E2> -
Maps the error from
E
toE2
if it is Err, else, keeps the Ok,T
.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
-
unwrap(
) → T -
Unsafe operations that returns
T
or throwE
inherited -
unwrapErr(
) → E -
Unsafe operations that returns
E
or throw an Exceptioninherited -
unwrapOrNull(
) → T? -
Returns
T
on Ok, ornull
on Errinherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited