Skip to content

Commit 35f1fb8

Browse files
committed
fix: 파라미터 검증 및 커스텀 에러 메시지 지원
1 parent 24e7883 commit 35f1fb8

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/main/java/com/ongil/backend/global/common/dto/ErrorResponse.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,14 @@ public static ErrorResponse of(ErrorCode errorCode, HttpServletRequest request)
3232
errorCode.getHttpStatus()
3333
);
3434
}
35+
36+
public static ErrorResponse of(ErrorCode errorCode, String message, HttpServletRequest request) {
37+
return new ErrorResponse(
38+
errorCode.getCode(),
39+
message,
40+
request.getMethod(),
41+
request.getRequestURI(),
42+
errorCode.getHttpStatus()
43+
);
44+
}
3545
}

src/main/java/com/ongil/backend/global/common/exception/GlobalExceptionHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ public class GlobalExceptionHandler {
1919
// AppException 처리
2020
@ExceptionHandler(AppException.class)
2121
public ResponseEntity<ErrorResponse> handleAppException(AppException e, HttpServletRequest request) {
22-
log.error("AppException 발생: {}", e.getErrorCode().getMessage());
22+
log.error("AppException 발생: {}", e.getMessage());
2323
log.error("에러가 발생한 지점: {} {}", request.getMethod(), request.getRequestURI());
2424

25-
ErrorResponse errorResponse = ErrorResponse.of(e.getErrorCode(), request);
25+
ErrorResponse errorResponse = ErrorResponse.of(e.getErrorCode(), e.getMessage(), request);
2626
return ResponseEntity
2727
.status(e.getErrorCode().getHttpStatus())
2828
.body(errorResponse);

0 commit comments

Comments
 (0)