Files
main.tsmain
What you'll learn
- Describe what the exceptions layer answers for an HttpException and for a plain Error, and why the two differ
- Write an exception filter with @Catch(), ArgumentsHost and the response object, scoped to one exception family
- Bind a filter globally and know which errors a global filter sees that a controller-scoped one does not
Press Run tests to start the app. Its log appears here.Graded endpoints
A successful response is never touched by a filter: nothing was thrown
NotFoundException from the service, shaped by the filter; the timestamp is not compared
BadRequestException from the service, shaped by the filter; the plain Error it replaced would have been an opaque 500
No controller matched, so only a global filter can shape this 404
Not an HttpException, so a filter for HttpException leaves it alone and Nest's default 500 body answers
A valid body still creates a cat