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.