getOrThrow method

T getOrThrow()

Returns the data on success, or throws a ResultUnwrapException on failure.

Use sparingly — the whole point of Result is that callers are forced to handle the failure path. Reach for getOrElse or when first.

Implementation

T getOrThrow() => switch (this) {
      Success<T>(:final data) => data,
      Error<T>(:final failure) => throw ResultUnwrapException(failure),
    };