errorOrThrow method

Failure errorOrThrow()

Returns the wrapped failure on error, or throws a StateError on success. Symmetric counterpart to getOrThrow.

Implementation

Failure errorOrThrow() => switch (this) {
      Success<T>(:final data) => throw StateError(
          'Called errorOrThrow on a Success: $data',
        ),
      Error<T>(:final failure) => failure,
    };