Skip to content

Commit

Permalink
feat: HttpMessageNotReadableException 핸들러 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
SJ70 committed Jul 19, 2024
1 parent b2c8b79 commit b12f842
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.springframework.context.support.DefaultMessageSourceResolvable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
Expand All @@ -27,4 +28,10 @@ protected ResponseEntity<String> handleMethodArgumentNotValidException(MethodArg
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(msg);
}

// 잘못된 형식, 매핑 실패, 필드 누락
@ExceptionHandler(HttpMessageNotReadableException.class)
protected ResponseEntity<String> handleHttpMessageNotReadableException(HttpMessageNotReadableException e) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
}

}

0 comments on commit b12f842

Please sign in to comment.