catchError<Error extends DomainException, Success> method

  1. @protected
Success? catchError<Error extends DomainException, Success>(
  1. Either<Error, Success?> result, [
  2. void success(
    1. Success success
    )?
])

Unwraps the error and guides it to the errorProvider after converting Data to Domain errors

Implementation

@protected
Success? catchError<Error extends DomainException, Success>(
  Either<Error, Success?> result, [
  void Function(Success success)? success,
]) {
  return result.fold(
    (e) {
      setError(e);
      return null;
    },
    (e) {
      if (e != null) {
        success?.call(e);
      }
      return e;
    },
  );
}