@RestControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler({IllegalArgumentException.class})
public ResponseEntity<RestApiException> handleException(IllegalArgumentException ex) {
RestApiException restApiException = new RestApiException(ex.getMessage(), HttpStatus.BAD_REQUEST.value());
return new ResponseEntity<>(
// HTTP body
restApiException,
// HTTP status code
HttpStatus.BAD_REQUEST
);
}
}'TIL' 카테고리의 다른 글
| JPA 연관관계 (0) | 2024.10.01 |
|---|---|
| 회의 메모 (0) | 2024.09.27 |
| if 조건문 최소화 하기 (0) | 2024.09.06 |
| Code Convention 도구 "Spotless" (0) | 2024.09.05 |
| 팀과제 피드백 (0) | 2024.09.04 |