Skip to content

Commit efb4b13

Browse files
authored
Merge pull request #84 from gsainfoteam/yhkim13/pgb-51
yhkim13/pgb-51 to develop
2 parents 62b50ca + 0002946 commit efb4b13

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/global/filters/all-exception.filter.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
HttpException,
66
HttpStatus,
77
Logger,
8+
UnauthorizedException,
89
} from "@nestjs/common";
910
import { Request, Response } from "express";
1011
import { SlackService } from "nestjs-slack";
@@ -17,16 +18,26 @@ export class AllExceptionsFilter implements ExceptionFilter {
1718
constructor(private readonly slackService: SlackService) {}
1819

1920
catch(exception: unknown, host: ArgumentsHost) {
21+
const ctx = host.switchToHttp();
22+
const response = ctx.getResponse<Response>();
23+
24+
// 이미 HttpExceptionFilter 및 WsExceptionFilter에서 처리된 예외는 무시
2025
if (
2126
exception instanceof HttpException ||
2227
exception instanceof WsException
2328
) {
24-
// 이미 HttpExceptionFilter 및 WsExceptionFilter에서 처리된 예외는 무시
29+
// 다만 UnauthorizedException 은 HttpExceptionFilter에서 처리되지 않으므로 여기서 로깅 없이 처리
30+
if (exception instanceof UnauthorizedException) {
31+
const status = exception.getStatus();
32+
response.status(status).json({
33+
statusCode: status,
34+
message: exception.message,
35+
});
36+
}
37+
2538
return;
2639
}
2740

28-
const ctx = host.switchToHttp();
29-
const response = ctx.getResponse<Response>();
3041
const request = ctx.getRequest<Request>();
3142

3243
// Critical 에러 로깅 (스택 트레이스 및 상세 정보 포함)

0 commit comments

Comments
 (0)