NestJS crashing on throwing http exception

Viewed 930
main.controller.ts:135
throw new NotFoundException('Swap not found');
^
NotFoundException: Swap not found

I have a pretty simple request in a controller

@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,
    }
}

After the exception is thrown, NestJS also stops from running!? How do I avoid this? I know about the exception filters, but that's for custom exceptions, right? I use a default one.

Still, just in case, I've added a global one to test and same behaviour: app.useGlobalFilters(new HttpExceptionFilter());

Is this an expected behavior?

0 Answers
Related