import { LogLevel } from '../intf/ILogger' import { IRequestOptions } from '../intf/IRequestOptions' /** 上报异常 */ export const reportError = () => { return function (_target: any, _methodName: any, desc: any) { // 1. 保存当前的方法 const oMethod = desc.value // 2. 改写方法 desc.value = async function (req: IRequestOptions) { try { return await oMethod.apply(this, [req]) } catch (error) { this.logger?.log(LogLevel.Error, error) throw error } } } }