API reference / @backpack/error-handling / promises / recoverIfInstanceOf
Function: recoverIfInstanceOf()
ts
function recoverIfInstanceOf<TError, TResult>(errorClass, errorConverter): (e) => TResult;
If failed, maps the error to a value if it is an instance of the provided error class.
Can be applied on the .catch()
method of a Promise
to recover from specific errors.
Type Parameters
Type Parameter |
---|
TError |
TResult |
Parameters
Parameter | Type |
---|---|
errorClass | Class <TError > |
errorConverter | (error ) => TResult |
Returns
ts
(e): TResult;
Parameters
Parameter | Type |
---|---|
e | unknown |
Returns
TResult