Skip to content

ignoreError<T>

Ignores an error that is thrown by an asynchronous function.

Import:

import { ignoreError } from '@mnaoumov/typescript-lib/async';

Signature:

function ignoreError(promise: Promise<T>, fallbackValue: T | undefined): Promise<void | T>

Parameters:

Parameter Type Description
promise Promise<T> The promise to ignore the error of.
fallbackValue T | undefined The value to return if an error is thrown.

Returns: Promise<void | T> — A Promise that resolves with the value returned by the asynchronous function or the fallback value if an error is thrown.