Codibre/remembered-redis

View on GitHub
src/try-to-factory.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import { Action, LogError, TryTo } from './remembered-redis-config';

export function tryToFactory(logError: LogError | undefined): TryTo {
    return async function <T>(action: Action<T>) {
        try {
            return await action();
        } catch (err: any) {
            logError?.(err.message);
        }
    };
}