Skip to content

Commit 01ae08b

Browse files
committed
- fix: ignore already handled HttpException and WsException in all-exception filter
1 parent a97d2c3 commit 01ae08b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import {
22
ArgumentsHost,
33
Catch,
44
ExceptionFilter,
5+
HttpException,
56
HttpStatus,
67
Logger,
78
} from "@nestjs/common";
89
import { Request, Response } from "express";
910
import { SlackService } from "nestjs-slack";
11+
import { WsException } from "@nestjs/websockets";
1012

1113
@Catch() // 모든 예외를 캐치
1214
export class AllExceptionsFilter implements ExceptionFilter {
@@ -15,6 +17,14 @@ export class AllExceptionsFilter implements ExceptionFilter {
1517
constructor(private readonly slackService: SlackService) {}
1618

1719
catch(exception: unknown, host: ArgumentsHost) {
20+
if (
21+
exception instanceof HttpException ||
22+
exception instanceof WsException
23+
) {
24+
// 이미 HttpExceptionFilter 및 WsExceptionFilter에서 처리된 예외는 무시
25+
return;
26+
}
27+
1828
const ctx = host.switchToHttp();
1929
const response = ctx.getResponse<Response>();
2030
const request = ctx.getRequest<Request>();

0 commit comments

Comments
 (0)