[Feat/#18] 공통 예외 처리(GlobalExceptionHandler) 추가 - #20
Merged
Conversation
BusinessException·Validation 예외·그 외 Exception을 ApiResponse 포맷으로 변환하는 GlobalExceptionHandler를 추가한다. MDC 로그 상관관계를 위한 MdcKeys(REQUEST_ID, USER_ID) 상수도 함께 추가한다.
github-actions
Bot
requested review from
leegain1,
sangrae2325 and
tnals0924
September 9, 2026 02:57
sangrae2325
approved these changes
Sep 9, 2026
xeoxxn
approved these changes
Sep 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#️⃣연관된 이슈
🎯 해결하려는 문제가 무엇인가요?
BusinessException을 던져도 이를ApiResponse포맷으로 변환해주는 공통 예외 처리기가 없어서, 도메인 서비스에서 예외를 던지면 Spring 기본 에러 바디(500,ApiResponse형식 아님)가 그대로 나갑니다.❓ 왜 해결해야 하나요?
이후 추가되는 모든 API(공지 API #19 포함)가
BusinessException기반 에러 응답을 정상적으로 내려주려면 반드시 필요합니다.⭐ 어떻게 해결했나요?
docs/conventions/error-handling.md4절에 문서화된 설계 그대로 구현했습니다.gateway:logging에MdcKeys(REQUEST_ID,USER_ID) 상수 추가api:common-api에GlobalExceptionHandler(@RestControllerAdvice) 추가BusinessException→ApiResponse.error(e)+ warn 로그MethodArgumentNotValidException→CommonErrorCode.INVALID_INPUT+ warn 로그Exception→CommonErrorCode.INTERNAL_SERVER_ERROR+ error 로그🧩 이 PR의 한계 & 트레이드오프
@ApiErrorCode/ApiErrorCodeCustomizer기반 Swagger 에러 문서화(error-handling.md 6절)는 이번 PR에서 제외했습니다. springdoc 등 새 의존성 추가가 필요해서 스코프를 벗어난다고 판단했습니다.⛓️ 기존 기능에 미치는 영향
신규 추가 클래스 2개뿐이라 기존 코드에 영향 없습니다.
🔀 Edge Case & 실패 시나리오
BusinessException이 아닌 예상 못한 런타임 예외 →Exception핸들러가 잡아 500 +INTERNAL_SERVER_ERROR로 통일된 포맷 응답requestId/userId가 아직 채워지지 않는 상태(MdcFilter 미구현)라 로그에는 당분간null로 찍힘 — 별도 이슈로 후속 처리 필요📋 검토한 대안과 선택 이유
문서에 이미 합의된 설계가 있어 별도 대안 검토 없이 그대로 구현했습니다.
💬 리뷰 포인트
[r]MDC 키가 아직 채워지지 않아 로그 상관관계 확인이 어려운 점 — 별도 이슈로 뺄지 확인 부탁드립니다