Skip to content

Commit

Permalink
fix: http not support method exception 핸들러에 반영 (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
psychology50 authored Aug 7, 2024
1 parent 03994d7 commit b88d70c
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.springframework.http.converter.HttpMessageNotWritableException;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.validation.BindingResult;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.MissingRequestHeaderException;
import org.springframework.web.bind.MissingServletRequestParameterException;
Expand Down Expand Up @@ -55,6 +56,21 @@ protected ResponseEntity<ErrorResponse> handleGlobalErrorException(GlobalErrorEx
return ResponseEntity.status(e.getBaseErrorCode().causedBy().statusCode().getCode()).body(response);
}

/**
* API 호출 시 'Method' 내에 데이터 값이 유효하지 않은 경우
*
* @see HttpRequestMethodNotSupportedException
*/
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
@JsonView(CustomJsonView.Common.class)
protected ErrorResponse handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) {
log.warn("handleHttpRequestMethodNotSupportedException : {}", e.getMessage());
String code = String.valueOf(StatusCode.BAD_REQUEST.getCode() * 10 + ReasonCode.INVALID_REQUEST.getCode());

return ErrorResponse.of(code, e.getMessage());
}

/**
* API 호출 시 'Header' 내에 데이터 값이 유효하지 않은 경우
*
Expand Down

0 comments on commit b88d70c

Please sign in to comment.