```java @RestControllerAdvice public class GlobalExceptionHandler { @ExceptionHandler(BadRequestException.class) public ResponseEntity<String> handleBadRequestException(BadRequestException e){ return ResponseEntity .status(HttpStatus.BAD_REQUEST) .body(e.getMessage()); } @ExceptionHandler(EntityNotFoundException.class) public ResponseEntity<String> handleEntityNotFoundException(EntityNotFoundException e){ return ResponseEntity .status(HttpStatus.NOT_FOUND) .body("Requested resource does not exist"); } @ExceptionHandler(Exception.class) public ResponseEntity<String> handleGeneralException(Exception e) { return ResponseEntity .status(HttpStatus.INTERNAL_SERVER_ERROR) .body("Internal Server Error: An unexpected error occurred"); } } ``` ## [[4-4. 컨트롤러 테스트 코드(검증 & 예외처리)|테스트 코드]] ![[4-4. 컨트롤러 테스트 코드(검증 & 예외처리)#`ValidationAndExceptionTest` 작성]]