mapErrOr<F> abstract method

  1. @useResult
F mapErrOr<F>(
  1. F map(
    1. E error
    ),
  2. F defaultError
)

Returns the contained error, if any, with map applied to it, or defaultError otherwise.

Examples

// prints "4"
print(const Ok<int, String>(2).mapErrOr((error) => '$error!', 'other'));

// prints "0"
print(const Err<int, String>('error').mapErrOr((error) => '$error!', 'other'));

Implementation

@useResult
F mapErrOr<F>(F Function(E error) map, F defaultError);