Skip to content

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

@sarancruzer

Description

@sarancruzer

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions