diff --git a/backend/src/main/java/org/donggle/backend/ui/common/GlobalExceptionHandler.java b/backend/src/main/java/org/donggle/backend/ui/common/GlobalExceptionHandler.java index 3bfc6f720..bea6582bd 100644 --- a/backend/src/main/java/org/donggle/backend/ui/common/GlobalExceptionHandler.java +++ b/backend/src/main/java/org/donggle/backend/ui/common/GlobalExceptionHandler.java @@ -8,6 +8,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; import org.springframework.web.bind.MissingPathVariableException; @@ -116,6 +117,17 @@ public ResponseEntity handleHttpMessageNotReadableException(final .body(errorResponse); } + @ExceptionHandler(HttpMediaTypeNotSupportedException.class) + public ResponseEntity handleHttpMediaTypeNotSupportedException(final HttpMediaTypeNotSupportedException e) { + log.warn("Exception from handleHttpMediaTypeNotSupportedException = ", e); + final ErrorResponse errorResponse = new ErrorResponse( + "잘못된 요청입니다. 지원하지 않는 미디어 타입입니다. 지원되는 미디어 타입: " + e.getSupportedMediaTypes() + ); + return ResponseEntity + .status(HttpStatus.BAD_REQUEST) + .body(errorResponse); + } + @ExceptionHandler(Exception.class) public ResponseEntity handleUnExpectedException(final Exception e) { log.error("Exception from handleUnExpectedException = ", e);