Skip to content

Commit df15775

Browse files
authored
Merge pull request #396 from Quickchive/fix/add-optional-chain-to-exception-filter
fix: 예외 필터 타입 에러 수정
2 parents 0f1f9c4 + 42babd5 commit df15775

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/common/exceptions/http-exception.filter.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import {
2-
ExceptionFilter,
3-
Catch,
42
ArgumentsHost,
3+
Catch,
4+
ExceptionFilter,
55
HttpException,
6+
HttpStatus,
67
} from '@nestjs/common';
78
import { Request, Response } from 'express';
89
import { logger } from '../logger';
@@ -37,7 +38,10 @@ export class HttpExceptionFilter implements ExceptionFilter {
3738
const ctx = host.switchToHttp();
3839
const response = ctx.getResponse<Response>();
3940
const request = ctx.getRequest<Request>();
40-
const status = exception.getStatus();
41+
const status =
42+
exception instanceof HttpException
43+
? exception.getStatus()
44+
: HttpStatus.INTERNAL_SERVER_ERROR;
4145
const { ip, method, url } = request;
4246
logger.error(
4347
`${method} - ${url} - ${ip.split(':').at(-1)} - ${JSON.stringify(

0 commit comments

Comments
 (0)