inspectErr method

Result<T, E> inspectErr(
  1. void action(
    1. E error
    )
)

Calls action with the error, and returns this result unchanged.

final saved = const Err<int, String>('locked')
    .inspectErr((error) => print('save failed: $error'));

Implementation

Result<T, E> inspectErr(void Function(E error) action) {
  if (this case Err<T, E>(:final error)) action(error);
  return this;
}