API reference / @backpack/error-handling / promises / recoverIf
Function: recoverIf()
Call Signature
ts
function recoverIf<TError, TResult>(predicate, errorConverter): (error) => TResult;
If failed, maps the error to another value if it matches the given type guard.
Can be applied on the .catch()
method of a Promise
.
Type Parameters
Type Parameter |
---|
TError |
TResult |
Parameters
Parameter | Type |
---|---|
predicate | (error ) => error is TError |
errorConverter | (error ) => TResult |
Returns
ts
(error): TResult;
Parameters
Parameter | Type |
---|---|
error | unknown |
Returns
TResult
Call Signature
ts
function recoverIf<TResult>(predicate, errorConverter): (error) => TResult;
If failed, maps the error to another value if it matches the given predicate.
Can be applied on the .catch()
method of a Promise
.
Type Parameters
Type Parameter |
---|
TResult |
Parameters
Parameter | Type |
---|---|
predicate | (error ) => boolean |
errorConverter | (error ) => TResult |
Returns
ts
(error): TResult;
Parameters
Parameter | Type |
---|---|
error | unknown |
Returns
TResult