main.controller.ts:135
throw new NotFoundException('Swap not found');
^
NotFoundException: Swap not found
Run Code Online (Sandbox Code Playgroud)
我在控制器中有一个非常简单的请求
@Get("/details")
@ApiResponse({
status: 200,
description: 'Returns the details',
})
async getDetails(
@Query('id') id: string
): Promise<Result> {
let details = await this.databaseService.find(id)
if (!details) {
throw new NotFoundException('Swap not found');
}
return {
details: details,
}
}
Run Code Online (Sandbox Code Playgroud)
抛出异常后,NestJS也停止运行了!?我该如何避免这种情况?我知道异常过滤器,但那是针对自定义异常的,对吧?我用的是默认的。
不过,为了以防万一,我添加了一个全局的来测试和相同的行为:app.useGlobalFilters(new HttpExceptionFilter());
这是预期的行为吗?
| 归档时间: |
|
| 查看次数: |
2737 次 |
| 最近记录: |