@kaelyx/ts-kit / result / err
Function: err()
err<
E>(error):Result<never,E>
Defined in: result/err/err.ts:19
Creates a failed Result that holds the given error.
Type Parameters
E
E
Parameters
error
E
The error to hold. Falsy values such as undefined, '' or 0 are kept as they are.
Returns
Result<never, E>
A Result with ok: false and the error in the error property.
Example
ts
err('Something went wrong') // { ok: false, error: 'Something went wrong' }
err(new Error('Boom')) // { ok: false, error: Error('Boom') }