Skip to content

UseAttempt

katanakit-js / useAttempt

function useAttempt<T>(operation, mapError?): Promise<SafeResult<T>>;

Defined in: core/services/result.service.ts:105

Runs an operation and captures any throw as a Safe Result. See ResultService.useAttempt.

Type Parameter
T
Parameter Type Default value
operation () => T | Promise<T> undefined
mapError? (error) => { details?: unknown; message: string; status: number; } useErrorNormalize

Promise<SafeResult<T>>