isErrAnd method

bool isErrAnd(
  1. bool predicate(
    1. E error
    )
)

Whether the result failed and its error satisfies predicate.

predicate is not called for an Ok.

final retry = const Err<int, int>(503).isErrAnd((status) => status >= 500);

Implementation

bool isErrAnd(bool Function(E error) predicate) {
  return switch (this) {
    Ok<T, E>() => false,
    Err<T, E>(:final error) => predicate(error),
  };
}