Hi, I'm a beginner backend developer from South Korea studying to become a good developer.
I was wondering the best way to handle errors in NestJS (not microservices). REST API
The way I'm handling it now, is to handle exceptions at the service layer, catch them with a filter and respond in a common format.
https://github.com/nestjs/nest/issues/310
Based on that link, I was thinking about shekohex's solution, but I don't think the code would be clean as there would be a lot of try catches between the repository layer, service layer, and controller layer.
Also, it is said that it is not allowed to throw a NotFoundException directly from the service layer when there is no record inside the database.
So I'm curious to hear your methods or opinions on where and how to handle the exception.
P.S.
If there are any grammatical errors or poor word choices in what I have written, please be understanding. 🥹