unwrap method
T
unwrap()
Returns the success value, or throws the error with its original stack trace.
This is the most direct way to extract the value. Use with caution—only when you're certain the result should be Ok or want to fail hard if it's not. For safer extraction with fallbacks, use unwrapOr, unwrapOrNull, or expect instead.
The original stack trace is preserved when throwing, making debugging easier.
Implementation
T unwrap() => switch (this) {
Ok(:final value) => value,
Err(:final error, :final stackTrace) => Error.throwWithStackTrace(
error,
stackTrace,
),
};