Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
[BE] fix: HttpMediaTypeNotSupportedException Handler μΆ”κ°€ (#181)
Browse files Browse the repository at this point in the history
fix: HttpMediaTypeNotSupportedException Handler μΆ”κ°€

Co-authored-by: ingpyo <[email protected]>
  • Loading branch information
echo724 and ingpyo authored Aug 3, 2023
1 parent 98217b9 commit 3971a56
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -116,6 +117,17 @@ public ResponseEntity<ErrorResponse> handleHttpMessageNotReadableException(final
.body(errorResponse);
}

@ExceptionHandler(HttpMediaTypeNotSupportedException.class)
public ResponseEntity<ErrorResponse> 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<ErrorResponse> handleUnExpectedException(final Exception e) {
log.error("Exception from handleUnExpectedException = ", e);
Expand Down

0 comments on commit 3971a56

Please sign in to comment.