onFailure method

Try<Success, Failure> onFailure(
  1. void action(
    1. Failure
    )
)

Performs the given action on the encapsulated Throwable exception if this instance represents failure. Returns the original Try unchanged.

Implementation

Try<Success, Failure> onFailure(void Function(Failure) action) {
  if (isFailure) {
    action(exceptionOrNull()!);
  }
  return this;
}