UNPKG

@playerony/try-catch-wrapper

Version:
26 lines (22 loc) 894 B
/** * @packageDocumentation Functional try-catch wrapper. */ /** * try-catch wrapper for asynchronous functions * * @param toExecute - asynchronous function to execute inside of try-catch * @param onError - asynchronous function to execute when an error occurs * * @public */ export declare const asyncTryCatchWrapper: <TData = unknown, TError = unknown>(toExecute: () => Promise<TData>, onError?: ((error: TError) => void) | undefined) => Promise<void | TData>; /** * try-catch wrapper for synchronous functions * * @param toExecute - synchronous function to execute inside of try-catch * @param onError - synchronous function to execute when an error occurs * * @public */ export declare const tryCatchWrapper: <TData = unknown, TError = unknown>(toExecute: () => TData, onError?: ((error: TError) => void) | undefined) => void | TData; export { }