#How to catch Exception in interceptor in catchError operator

4 messages · Page 1 of 1 (latest)

wind raven
#

I'm getting in Postman a 200 status from thrown exception (status 404) from the controller and passed through the interceptor. I've read this https://docs.nestjs.com/exception-filters#catch-everything and use it in interceptor class but I tried some way and I'm getting differents errors, How can I get an approach that I could use to throw the status that I need and also passing through the interceptor?. You could see my shared question in Stack overFlow https://stackoverflow.com/questions/76372124/how-to-catch-exception-in-interceptor-inside-catcherror-operator

shrewd fern
#

Interceptors trigger before the res status has been set from the filter if there is an exception. With ogma, I have it mimic what nest's behavior would be and call it close enough. Otherwise, just reading res.status you'll pretty much always read a 200

wind raven
#

I reach an approach that get me close of what I want you can check it out and give some feedback would be nice -> https://stackoverflow.com/questions/76372124/how-to-catch-exception-in-interceptor-inside-catcherror-operator

tranquil lily
#

Here's a snippet of my approach to the problem: