import ErrorMatch from "./ErrorMatch"; import errorMatches from "./errorMatches"; export default Promise>( realFn: F, errorMatch?: ErrorMatch ): F & ((...args: any[]) => Promise) => { return async function (this: any, ...args: any[]) { try { return await realFn.apply(this, args); } catch (error) { if (errorMatch == undefined || errorMatches(error, errorMatch)) { return undefined; } throw error; } } as any; };