File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 55 HttpException ,
66 HttpStatus ,
77 Logger ,
8+ UnauthorizedException ,
89} from "@nestjs/common" ;
910import { Request , Response } from "express" ;
1011import { 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 에러 로깅 (스택 트레이스 및 상세 정보 포함)
You can’t perform that action at this time.
0 commit comments