aboutsummaryrefslogblamecommitdiffstats
path: root/packages/deployer/src/utils/error_reporter.ts
blob: 4e73307f014888fb0c32c8b224ed03c576464dc5 (plain) (tree)
1
2
3
4
5
6
7
8

                                            





                                                                                                   









                                              
import { logUtils } from '@0xproject/utils';

/**
 * Makes an async function no-throw printing errors to the console
 * @param asyncFn async function to wrap
 * @return Wrapped version of the passed function
 */
export function consoleReporter<T>(asyncFn: (arg: T) => Promise<void>): (arg: T) => Promise<void> {
    const noThrowFnAsync = async (arg: T) => {
        try {
            const result = await asyncFn(arg);
            return result;
        } catch (err) {
            logUtils.log(`${err}`);
        }
    };
    return noThrowFnAsync;
}