Function: fail()
Creates a Failure result from a given error.
Automatically wraps the error in a Promise
if it is asynchronous.
Type Param
The type of the error to wrap.
Examples
import { Result } from '@praha/byethrow';
const result = Result.fail('Something went wrong');
// Result.Result<never, string>
import { Result } from '@praha/byethrow';
const result = Result.fail(Promise.resolve('Async error'));
// Result.ResultAsync<never, string>
import { Result } from '@praha/byethrow';
const result = Result.fail();
// Result.Result<never, void>
See
combine - For combining multiple Results into a single Result.
Call Signature
fail(): Result
<never
, void
>
Defined in: functions/fail.ts:44
Returns
Result
<never
, void
>
Call Signature
fail<E
>(error
): ResultFor
<E
, never
, Awaited
<E
>>
Defined in: functions/fail.ts:45
Type Parameters
E
E
Parameters
error
E
Returns
ResultFor
<E
, never
, Awaited
<E
>>