Docs:
@Get('error') Error(@Query('name') name){ if(!name) throw new HttpException('错误示例。', HttpStatus.FORBIDDEN) return '什么事都没有: ' + name; }// 也可以传递 object if(!name) throw new HttpException({ error: '错误示例。', status: HttpStatus.FORBIDDEN }, 403)
访问http://localhost:5000/error,将会得到: {"statusCode":403,"message":"错误示例。"}