param { Function } fn param { Function } errorHandler returns export function transformErrors < T extends Function > ( fn , errorHandler ) { return ( ( async ( ... args ) : Promise < any > => { try { return await fn ( ... args ) ; } catch ( err ) { return errorHandler ( err ) ; } } ) as any ) as T ; }