import { maskAndLogError } from './mask-and-log-error' ; export template F param { F } resolver param { ( err : any ) => any } formatFunction returns { ( ... args : Parameters < F > ) => Promise < ReturnType < F > > } export function formatError < F extends ( ... args : any [ ] ) => any > ( resolver , formatFunction = maskAndLogError ) { return async ( ... args ) => { try { return await resolver ( ... args ) ; } catch ( error ) { throw await formatFunction ( error ) ; } } ; }