addErrorHandler
Adds an error handler to a Promise that catches any errors and emits an async error event.
Import:
import { addErrorHandler } from '@mnaoumov/typescript-lib/async';Signature:
function addErrorHandler(asyncFunction: () => Promise<unknown>, stackTrace: string | undefined): Promise<void>Parameters:
| Parameter | Type | Description |
|---|---|---|
asyncFunction |
() => Promise<unknown> | The asynchronous function to add an error handler to. |
stackTrace |
string | undefined | The stack trace of the source function. |
Returns: Promise<void> — A Promise that resolves when the asynchronous function completes or emits async error event.