@@ -47,25 +47,23 @@ public ResponseEntity<ErrorResponse> handleAuthException(JwtException e) {
4747 }
4848
4949 @ ExceptionHandler (Exception .class )
50- public ResponseEntity handleException (Exception e ){
50+ public ResponseEntity < ErrorResponse > handleException (Exception e ){
5151 log .warn ("[Exception] cause: {} , message: {}" , NestedExceptionUtils .getMostSpecificCause (e ), e .getMessage ());
5252 ErrorMessage errorCode = ErrorMessage .INTERNAL_SERVER_ERROR ;
5353 return ResponseEntity
5454 .status (errorCode .getStatus ())
5555 .body (ErrorResponse .of (errorCode .getStatus (), errorCode .getMessage ()));
5656 }
5757
58- //메소드가 잘못되었거나 부적합한 인수를 전달했을 경우 -> 필수 파라미터 없을 때
5958 @ ExceptionHandler (IllegalArgumentException .class )
60- public ResponseEntity handleIllegalArgumentException (IllegalArgumentException e ){
59+ public ResponseEntity < ErrorResponse > handleIllegalArgumentException (IllegalArgumentException e ){
6160 log .warn ("[IlleagalArgumentException] cause: {} , message: {}" , NestedExceptionUtils .getMostSpecificCause (e ), e .getMessage ());
6261 ErrorMessage errorCode = ErrorMessage .ILLEGAL_ARGUMENT_ERROR ;
6362 return ResponseEntity
6463 .status (errorCode .getStatus ())
6564 .body (ErrorResponse .of (errorCode .getStatus (), errorCode .getMessage ()));
6665 }
6766
68- //@Valid 유효성 검사에서 예외가 발생했을 때 -> requestbody에 잘못 들어왔을 때
6967 @ ExceptionHandler (MethodArgumentNotValidException .class )
7068 public ResponseEntity <ErrorResponse > handleMethodArgumentNotValidException (MethodArgumentNotValidException e ){
7169 log .warn ("[MethodArgumentNotValidException] cause: {}, message: {}" , NestedExceptionUtils .getMostSpecificCause (e ), e .getMessage ());
@@ -75,7 +73,6 @@ public ResponseEntity<ErrorResponse> handleMethodArgumentNotValidException(Metho
7573 .body (ErrorResponse .of (errorCode .getStatus (), errorCode .getMessage ()));
7674 }
7775
78- //잘못된 포맷 요청 -> Json으로 안보내다던지
7976 @ ExceptionHandler (HttpMessageNotReadableException .class )
8077 public ResponseEntity <ErrorResponse > handleHttpMessageNotReadableException (HttpMessageNotReadableException e ){
8178 log .warn ("[HttpMessageNotReadableException] cause: {}, message: {}" , NestedExceptionUtils .getMostSpecificCause (e ), e .getMessage ());
@@ -84,6 +81,7 @@ public ResponseEntity<ErrorResponse> handleHttpMessageNotReadableException(HttpM
8481 .status (errorCode .getStatus ())
8582 .body (ErrorResponse .of (errorCode .getStatus (), errorCode .getMessage ()));
8683 }
84+
8785 @ ExceptionHandler (HttpRequestMethodNotSupportedException .class )
8886 public ResponseEntity <ErrorResponse > handleHttpMethodException (
8987 HttpRequestMethodNotSupportedException e ,
@@ -95,5 +93,4 @@ public ResponseEntity<ErrorResponse> handleHttpMethodException(
9593 .status (errorCode .getStatus ())
9694 .body (ErrorResponse .of (errorCode .getStatus (), errorCode .getMessage ()));
9795 }
98- }
99-
96+ }
0 commit comments