Function: assertFailure()
assertFailure<
R>(result):trueextendsHasPromise<R> ?Promise<Failure<InferFailure<R>>> :Failure<InferFailure<R>>
Asserts that a Result or ResultAsync is a Failure and returns it.
This function requires that the result's success type is never, meaning the result is
guaranteed to be a Failure at the type level.
If the result is a Success at runtime, throws an error.
Type Parameters
R
R extends ResultMaybeAsync<never, any>
The result type that extends ResultMaybeAsync with never as the success type.
Parameters
result
R
The Result or ResultAsync to assert as a Failure.
The success type must be never.
Returns
true extends HasPromise<R> ? Promise<Failure<InferFailure<R>>> : Failure<InferFailure<R>>
The Failure result or a Promise of Failure result.
Throws
If the result is a Success at runtime.
Examples
See
unwrapError - Use with assertFailure to safely unwrap error values.
