Skip to content

Commit

Permalink
Merge pull request #24 from gsainfoteam/siwonpada/issue21
Browse files Browse the repository at this point in the history
[BUG] exception filter를 달면서 생긴 문제 원인 분석 및 해결하기
  • Loading branch information
siwonpada authored Sep 26, 2024
2 parents 760ce0c + 3eac635 commit 482a470
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 49 deletions.
76 changes: 34 additions & 42 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@fastify/basic-auth": "^5.1.1",
"@fastify/cookie": "^9.4.0",
"@fastify/cors": "^9.0.1",
"@fastify/static": "^7.0.4",
"@nestjs-modules/ioredis": "^2.0.2",
"@nestjs-modules/mailer": "^1.6.1",
"@nestjs/axios": "^3.0.2",
Expand All @@ -33,14 +31,13 @@
"@nestjs/core": "^10.0.0",
"@nestjs/jwt": "^10.2.0",
"@nestjs/passport": "^10.0.3",
"@nestjs/platform-fastify": "^10.4.3",
"@nestjs/platform-fastify": "^10.4.4",
"@nestjs/swagger": "^7.3.0",
"@prisma/client": "^5.9.1",
"axios": "^1.6.7",
"bcryptjs": "^2.4.3",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"cookie-parser": "^1.4.6",
"ioredis": "^5.4.1",
"mjml": "^4.15.3",
"nodemailer": "^6.9.15",
Expand Down
6 changes: 3 additions & 3 deletions src/global/filter/exceptionLog.filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import {
HttpException,
Logger,
} from '@nestjs/common';
import { Response } from 'express';
import { FastifyReply } from 'fastify';

@Catch(HttpException)
export class ExceptionLogFilter implements ExceptionFilter {
private readonly logger = new Logger('HttpExceptionFilter');
catch(exception: HttpException, host: ArgumentsHost) {
const ctx = host.switchToHttp();
const response = ctx.getResponse<Response>();
const response = ctx.getResponse<FastifyReply>();
const request = ctx.getRequest();
const status = exception.getStatus();

Expand All @@ -24,7 +24,7 @@ export class ExceptionLogFilter implements ExceptionFilter {
exception.cause,
);

response.status(status).json({
response.status(status).send({
statusCode: status,
message: exception.message,
timestamp: new Date().toISOString(),
Expand Down

0 comments on commit 482a470

Please sign in to comment.