NestJS has a built-in exception layer that automatically catches unhandled errors and turns them into proper HTTP responses. You signal errors by throwing exceptions (often built-in HTTP exception classes), and Nest formats them into structured JSON responses with the right status code.
Throwing built-in HTTP exceptions
{ , , } ;
()
() {
user = ..(id);
(!user) {
();
}
user;
}
