例如:
const ErrorDecorator: MethodDecorator = (target: object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {const method = descriptor.value;try {method()} catch(err: any) {console.log(`%c自定义错误信息`, 'color: green;font-size: 30px');console.log(`%c${err.message}`, 'color: red;font-size:20px');}}class Player {@ErrorDecoratorpublic run() {throw new Error('运行错误啦')}}new Player().run()
