Skip to content

addErrorHandler

Adds an error handler to a Promise that catches any errors and emits an async error event.

Import:

import { addErrorHandler } from 'obsidian-dev-utils/async';

Signature:

function addErrorHandler(asyncFn: () => Promise<unknown>, stackTrace: string | undefined): Promise<void>

Parameters:

ParameterTypeDescription
asyncFn() => Promise<unknown>The asynchronous function to add an error handler to.
stackTracestring | undefinedThe stack trace of the source function.

Returns: Promise<void> — A Promise that resolves when the asynchronous function completes or emits async error event.