krish / graphql-federation-youtube-tutorial

This is the tutorial for GraphQL federation. you can find the video of this on https://youtu.be/cRoaE-qNiAU
6 stars 8 forks source link

Exception filters with GraphQL - HttpException getStatus() is not a function #1

Open sarancruzer opened 3 years ago

sarancruzer commented 3 years ago

I wrote my own exceptionFilter by implements @nestjs/common/ExceptionFilter:

@Catch()
export class HttpExceptionFilter implements ExceptionFilter {
  catch(exception: HttpException, response) {
    const statusCode = exception.getStatus();
    response.status(statusCode).json({
      statusCode: statusCode,
      success: false,
      message: exception.getMessage()
      data: null
    });
  }
}

Expected behavior

I can get the expected return rather than it reported an error said exception.getStatus() is not a function.

krish commented 3 years ago

why you wanted a solution like this? what you trying to achive?