UNPKG

@withstudiocms/config-utils

Version:

Utilities for managing configuration files

12 lines (11 loc) 676 B
import type { Result } from './dynamicResult.js'; /** * A utility function that wraps a promise or a synchronous function call in a try-catch block. * It returns a tuple where the first element is the result (or null if an error occurred) * and the second element is the error (or null if no error occurred). * * @param fn - The function to execute, which can be a promise or a synchronous function. * @returns A promise that resolves to a tuple containing the result and error. */ export declare function tryCatch<T, E = Error>(fn: () => T | Promise<T>): Promise<Result<T, E>>; export declare function tryCatch<T, E = Error>(value: Promise<T>): Promise<Result<T, E>>;