fix: 미정의 예외 로깅에서 메시지·스택 유실 수정

HttpException 이 아닌 예외를 Logger.error 두 번째 인자(스택 문자열 자리)에
Error 객체째로 넘겨, nest-winston 직렬화 과정에서 message/stack 이 사라지고
`{ stack: [ {} ] }` 로만 찍히던 문제를 수정. 메시지는 message 로, 스택은
문자열로 분리해 실제 원인이 로그에 남도록 한다.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-19 00:22:48 +09:00
parent a056d7f55a
commit 9b01fbaf2f
@@ -63,7 +63,15 @@ export class HttpExceptionFilter implements ExceptionFilter {
}
} else {
// 정의되지 않은 예외 → 운영팀이 추적 가능하도록 로그 + SYS_001 응답 유지
this.logger.error('Unhandled Exception', exception as Error);
// NestJS Logger 2번째 인자는 "스택 문자열"이어야 한다. Error 객체를 그대로 넘기면
// nest-winston 이 비열거 속성을 직렬화하며 메시지/스택을 잃어 `{ stack: [ {} ] }` 로 찍힌다.
// → 메시지는 message 로, 스택은 문자열로 분리해 실제 원인이 로그에 남도록 한다.
const message =
exception instanceof Error ? exception.message : String(exception);
this.logger.error(
`Unhandled Exception: ${message}`,
exception instanceof Error ? exception.stack : undefined,
);
}
response.status(status).json({