CodePark/ questions / Exception filters
START PRACTICINGPRACTICE
Backend question · NestJS › Exception filters

You want to customise logging for some errors but keep Nest's default responses for everything else. What is the intended approach?

Extend BaseExceptionFilter and call super.catch(exception, host) for the cases you don't handle

Extend BaseExceptionFilter and call super.catch(exception, host). BaseExceptionFilter contains Nest's built-in behaviour. So calling super.catch() hands the error to the default handling.

The other options don't work. "Return
next() from your filter's catch method" is wrong because filters have no next(). "Register two global filters" is wrong because once Nest chooses a filter, it doesn't fall through to another one.