[REFAC] 로그인 처리 코드 서버 로그 찍기 #18
Merged
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.
📣 Related Issue
📝 Summary
[기존 코드의 문제점]
단순한 예외(4xx, 5xx)만 던지고 외부 API가 제공하는 상세 에러 본문/구체적인 오류(예: 만료된 코드, 잘못된 시크릿 키 등)을 로그로 남기지 않았음
[수정한 코드]
에러 응답을 서버 로그에 상세히 남기는 코드를 구현하였습니다.
bodyToMono(String.class): 에러가 발생했을 때 서버가 보낸 응답 본문(Error Body)을 읽어옴defaultIfEmpty(...): 만약 응답 바디가 비어있을 경우 발생할 수 있는 오류를 방지하는 안전장치flatMap: 읽어온 에러 바디와 상태 코드를 조합하여 로깅(Logging)을 수행하고, 최종적으로 우리 시스템에 정의된 커스텀 예외로 변환WebClientErrorHandler: WebClient 공통 에러 핸들링을 도입했습니다.onStatus(HttpStatusCode::isError, res -> WebClientErrorHandler.handleApiError(res, "API명"))형태로 한 줄 선언하게 개선하였습니다.[에러 처리 흐름]
📬 Reference
-> 위와 같은 에러 문구가 서버 로그에 찍힘