mapError<V, E extends Exception> method

Result<S, E> mapError<V, E extends Exception>(
  1. E transform(
    1. F
    )
)

Maps a Result<S, F> to Result<S, E> by applying a function to a contained Failure value, leaving an Success value untouched.

This function can be used to pass through a successful result while applying transformation to Failure.

Implementation

Result<S, E> mapError<V, E extends Exception>(E Function(F) transform) {
  if (isSuccess) {
    return Success(_left.value);
  } else {
    return Failure(transform(_right.value));
  }
}