@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' 카테고리의 다른 글
spring boot 실행시 BeanCreationException (0) | 2024.09.19 |
---|---|
프로그래머스 SQL 문제풀이 성분으로 구분한 아이스크림 총 주문량 (1) | 2024.09.12 |
AOP 특강 (0) | 2024.09.11 |
테스트 코드 특강 (0) | 2024.09.10 |
예외처리와 공통응답 (0) | 2024.09.09 |