API 예외 처리에서 검증 오류를 400으로 분리 - #9
Open
github-actions[bot] wants to merge 1 commit into
Open
Conversation
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.
개요
handleApiRequest()의 예외 처리 로직을 보강하여 검증 실패는400 Bad Request, 예상치 못한 오류는500 Internal Server Error로 구분합니다.기술적 원인
기존
catch블록은 아래 코드처럼err.errors가 항상 존재한다고 가정했습니다.그러나 현재 직접 발생시키는
ValidationError에는errors배열이 없기 때문에, 검증 실패를 처리하는 도중TypeError가 추가로 발생할 수 있습니다. 또한 모든 실패를500으로 고정 반환해 입력 오류도 서버 장애처럼 보였습니다.수정 방향
err instanceof ValidationError로 검증 오류를 식별400, 그 외는500반환errors배열이 존재할 때만 상세 메시지 생성ValidationError자체는field: message형태로 설명 제공기대 효과
참고
원본 문제 구간:
🔍 원본 에러 로그 및 발생 Context 보기
Authored by PikiLand Engine