getOrThrow method
T
getOrThrow()
Returns the encapsulated value if this instance represents Success or throws the encapsulated error if it is Failure.
This function is a shorthand for getOrElse((error, _) => throw error).
Implementation
T getOrThrow() {
return switch (this) {
Success<T>(:final data) => data,
Failure(:final error, :final stackTrace) => Error.throwWithStackTrace(
error,
stackTrace ?? StackTrace.current,
),
};
}