replacePossibleErrorWith method

Result<T> replacePossibleErrorWith(
  1. Error newErr
)

If the Result is a Err, then replaces internal err with newErr value. And returns changed result; If the Result is a Ok, then return unchanged Result as is;

Implementation

Result<T> replacePossibleErrorWith(Error newErr) {
  if (isErr) {
    return Err(newErr);
  }
  return this;
}