Skip to content

Commit 6944983

Browse files
committed
refactor(exception): 유효성 검사 실패시 해당 메세지 출력하도록 변경
1 parent a56f303 commit 6944983

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/java/com/somemore/global/exception/handler/GlobalExceptionHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ ProblemDetail handleDuplicateException(final DuplicateException e) {
4949
@ExceptionHandler(MethodArgumentNotValidException.class)
5050
ProblemDetail handleMethodArgumentNotValid(final MethodArgumentNotValidException e) {
5151

52-
ProblemDetail problemDetail = ProblemDetail.forStatusAndDetail(HttpStatus.BAD_REQUEST, e.getMessage());
52+
String errorMessage = e.getBindingResult().getAllErrors().getFirst().getDefaultMessage();
53+
ProblemDetail problemDetail = ProblemDetail.forStatusAndDetail(HttpStatus.BAD_REQUEST, errorMessage);
5354

5455
problemDetail.setTitle("유효성 예외");
55-
problemDetail.setDetail("입력 데이터 유효성 검사가 실패했습니다. 각 필드를 확인해주세요.");
5656

5757
return problemDetail;
5858
}

0 commit comments

Comments
 (0)