NestJS · Middle · Question 26 of 75
How do you write a global filter that formats all errors as RFC 9457 problem details?
- ✓Correct answer: A class with
@Catch()(no arguments catches everything) implementingcatch(exception, host), registered withAPP_FILTER - 2A pipe on every route
- 3Override
HttpException.prototype.toString
Explanation
Map HttpExceptions to their status, unknown errors to 500 with a generic message, and log the real error with a request ID.