API reference / @backpack/error-handling / promises / onFailureIfInstanceOf
Function: onFailureIfInstanceOf()
ts
function onFailureIfInstanceOf<TError>(errorClass, errorConsumer): (error) => never;
Executes the given callback if failed, if the error is an instance of the class provided, letting the original error pass through.
Can be applied on .catch()
method of a Promise
to introduce a side effect, such as logging.
Type Parameters
Type Parameter |
---|
TError |
Parameters
Parameter | Type |
---|---|
errorClass | Class <TError > |
errorConsumer | (error ) => void |
Returns
ts
(error): never;
Parameters
Parameter | Type |
---|---|
error | unknown |
Returns
never