You should use exception filters in your case instead.
In your case you’ll need:
throw new BadRequestException(error);
Or you can use
throw new HttpException('Forbidden', HttpStatus.FORBIDDEN);
That will return
{
"statusCode": 403,
"message": "Forbidden"
}
Docs: https://docs.nestjs.com/exception-filters