Function: unwrapOrThrow()
Call Signature
unwrapOrThrow<
R
>(result
):UnwrapOk
<R
>
Defined in: index.ts:411
Unwraps a Result, returning the data for Ok results and throwing the error for Err results. Useful for integrating Result-based functions with traditional throw-based code.
Type Parameters
R
R
extends Result
<any
, any
>
Type of the Result to unwrap
Parameters
result
NonPromise
<R
>
The Result to unwrap
Returns
UnwrapOk
<R
>
Data from the Ok result
Throws
Error from the Err result
Example
unwrapOrThrow(ok("hello")); // "hello"
unwrapOrThrow(err(new Error("failed"))); // throws Error("failed")
Call Signature
unwrapOrThrow<
R
>(result
):Promise
<UnwrapOk
<R
>>
Defined in: index.ts:412
Unwraps a Result, returning the data for Ok results and throwing the error for Err results. Useful for integrating Result-based functions with traditional throw-based code.
Type Parameters
R
R
extends OrPromise
<Result
<any
, any
>>
Type of the Result to unwrap
Parameters
result
R
The Result to unwrap
Returns
Promise
<UnwrapOk
<R
>>
Data from the Ok result
Throws
Error from the Err result
Example
unwrapOrThrow(ok("hello")); // "hello"
unwrapOrThrow(err(new Error("failed"))); // throws Error("failed")