diff --git a/week02/seminar/demo/src/main/java/com/example/demo/common/GlobalExceptionHandler.java b/week02/seminar/demo/src/main/java/com/example/demo/common/GlobalExceptionHandler.java index 1e7e434..b35953c 100644 --- a/week02/seminar/demo/src/main/java/com/example/demo/common/GlobalExceptionHandler.java +++ b/week02/seminar/demo/src/main/java/com/example/demo/common/GlobalExceptionHandler.java @@ -1,9 +1,8 @@ package com.example.demo.common; -import com.example.demo.common.dto.ErrorMessage; import com.example.demo.common.dto.ErrorResponse; +import com.example.demo.exception.CustomValidateException; import com.example.demo.exception.NotFoundException; -import jakarta.persistence.EntityNotFoundException; import java.util.Objects; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -22,4 +21,9 @@ protected ResponseEntity handleNotFoundException(NotFoundExceptio return ResponseEntity.status(HttpStatus.NOT_FOUND).body(ErrorResponse.of(e.getErrorMessage())); } + @ExceptionHandler(CustomValidateException.class) + protected ResponseEntity handleNotFoundException(CustomValidateException e) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(ErrorResponse.of(e.getErrorMessage())); + } + }