Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.validation.FieldError;
import org.springframework.web.HttpMediaTypeNotSupportedException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
Expand All @@ -25,7 +26,7 @@ public class GlobalExceptionHandler {

@ExceptionHandler(NoResourceFoundException.class)
public ResponseEntity<Void> handleNoResourceFound(NoResourceFoundException exception) {
log.debug("No static resource: {}", exception.getResourcePath());
log.warn("No static resource: {}", exception.getResourcePath());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR 설명 수정이 필요해보입니다. 본문에는 “봇 스캔성 404 등 고빈도 노이즈는 DEBUG”라고 적혀 있는데, 현재 구현은 NoResourceFoundExceptionWARN으로 남기고 있습니다.

@ckdals4600 ckdals4600 Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인 감사합니다. 본문 수정 완료하였습니다!

return ResponseEntity.notFound().build();
}

Expand All @@ -34,64 +35,71 @@ public ResponseEntity<Void> handleNoResourceFound(NoResourceFoundException excep
========================= */
@ExceptionHandler(BusinessException.class)
public ResponseEntity<BaseResponse<String>> handleBusinessException(BusinessException ex) {
log.error(ex.getMessage(), ex);
if (ex.getErrorCode().getStatus().is5xxServerError()) {
log.error("BusinessException [{}]", ex.getErrorCode().getCode(), ex);
} else {
log.warn("BusinessException [{}]: {}", ex.getErrorCode().getCode(), ex.getMessage());
}
return ErrorResponse.build(ex.getErrorCode());
}

/* =========================
검증/바인딩 예외
검증/바인딩 예외 (모두 4xx)
========================= */
@ExceptionHandler(MethodArgumentNotValidException.class)
public ResponseEntity<BaseResponse<String>> handleMethodArgumentNotValid(MethodArgumentNotValidException ex) {
log.error(ex.getMessage(), ex);
log.warn("Validation failed: {} field error(s) - fields={}",
ex.getBindingResult().getErrorCount(),
ex.getBindingResult().getFieldErrors().stream()
.map(FieldError::getField).distinct().toList());
return ErrorResponse.build(CommonErrorCode.INVALID_INPUT_VALUE);
}

@ExceptionHandler(ConstraintViolationException.class)
public ResponseEntity<BaseResponse<String>> handleConstraintViolation(ConstraintViolationException ex) {
log.error(ex.getMessage(), ex);
log.warn("Constraint violation: {}", ex.getMessage());
return ErrorResponse.build(CommonErrorCode.INVALID_INPUT_VALUE);
}

@ExceptionHandler(MethodArgumentTypeMismatchException.class)
public ResponseEntity<BaseResponse<String>> handleTypeMismatch(MethodArgumentTypeMismatchException ex) {
log.error(ex.getMessage(), ex);
log.warn("Type mismatch: parameter '{}'", ex.getName());
return ErrorResponse.build(CommonErrorCode.TYPE_MISMATCH);
}

@ExceptionHandler(MissingServletRequestParameterException.class)
public ResponseEntity<BaseResponse<String>> handleMissingParam(MissingServletRequestParameterException ex) {
log.error(ex.getMessage(), ex);
log.warn("Missing request parameter: {}", ex.getParameterName());
return ErrorResponse.build(CommonErrorCode.MISSING_REQUEST_PARAMS);
}

@ExceptionHandler(HttpMessageNotReadableException.class)
public ResponseEntity<BaseResponse<String>> handleNotReadable(HttpMessageNotReadableException ex) {
log.error(ex.getMessage(), ex);
log.warn("Malformed request body");
return ErrorResponse.build(CommonErrorCode.BAD_REQUEST);
}

/* =========================
HTTP 관련 예외
HTTP 관련 예외 (모두 4xx)
========================= */
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public ResponseEntity<BaseResponse<String>> handleMethodNotSupported(HttpRequestMethodNotSupportedException ex) {
log.error(ex.getMessage(), ex);
log.warn("Method not supported: {}", ex.getMethod());
return ErrorResponse.build(CommonErrorCode.METHOD_NOT_ALLOWED);
}

@ExceptionHandler(HttpMediaTypeNotSupportedException.class)
public ResponseEntity<BaseResponse<String>> handleMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex) {
log.error(ex.getMessage(), ex);
log.warn("Media type not supported: {}", ex.getContentType());
return ErrorResponse.build(CommonErrorCode.HTTP_MEDIA_NOT_SUPPORT);
}

/* =========================
그 외 모든 예외
그 외 모든 예외 (예상 못 한 5xx)
========================= */
@ExceptionHandler(Exception.class)
public ResponseEntity<BaseResponse<String>> handleException(Exception ex) {
log.error(ex.getMessage(), ex);
log.error("Unhandled exception", ex);
return ErrorResponse.build(CommonErrorCode.INTERNAL_SERVER_ERROR);
}

Expand Down
Loading