0

My question is quite simple, I'm trying to use GlobalFilters with GlobalPipes, the pipes I use for validating the payload sent to the API and the filters are responsible to handle the error during execution of API calls. But when the pipe tries to validate and returns a negative result, the filter is replacing the returned pipe.

main.ts

const app = await NestFactory.create(MainModule);
app.useGlobalFilters(new PaymentGeneratorExceptionFilter())
app.useGlobalPipes(new ValidationPipe());
app.setGlobalPrefix('v1');

const port = process.env.PORT || 8080;
await app.listen(port);

What should I do in this case ? Is there a way to make the filter not catch the pipe errors?

Nils
  • 1,755
  • 3
  • 13
  • 25

1 Answers1

0

The problem is the ValidationPipe extends a HttpException and my PaymentGeneratorExceptionFilter catches a HttpException, so this is why the GlobalFilter changes the return of the GlobalPipe.

Just a misunderstanding on my part.

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77