mapErr<F> method
Maps a Result<T, E>
to Result<T, F>
by applying a function to a
contained Err
(failure) value,
leaving an Ok
(success) value untouched.
This function can be used to pass through a successful result while handling an error.
Examples
Basic usage:
String stringify(int x) => 'error code: $x';
Result<int, int> x = Ok(2);
expect(x.mapErr(stringify), Ok<int, String>(2));
Result<int, int> y = Err(13);
expect(y.mapErr(stringify), Errint, String>('error code: 13'));
Implementation
@override
Result<T, F> mapErr<F>(F Function(E error) errMap) {
return Err(errMap(e));
}