Home > @infiniteobjects/core-library-web > Async > tapCatch
Tap into a promise chain without affecting its value or state. Use this in a .catch()
method.
Signature:
static tapCatch<ErrorType = unknown>(tapHandler: (error: ErrorType) => unknown): (error: ErrorType) => Promise<never>;
Parameter | Type | Description |
---|---|---|
tapHandler | (error: ErrorType) => unknown | Any return value is ignored. Exceptions thrown in tapHandler are relayed back to the original promise chain. If tapHandler returns a Promise , it will be awaited before passing through the original value. |
Returns:
(error: ErrorType) => Promise<never>
A [thunk](https://en.wikipedia.org/wiki/Thunk) that returns a Promise
.
import { Promises } from '@infiniteobjects/core-library';
Promise.resolve(() => doSomething())
.catch(Async.tapCatch(console.error)) // prints any errors
.then(handleSuccess)
.catch(handleError);