Skip to content

Commit

Permalink
feat : 3차 세미나 실습 과제_CustomValidateException GlobalExceptionHandler에 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
PicturePark1101 committed May 1, 2024
1 parent e1438ea commit beda91d
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -22,4 +21,9 @@ protected ResponseEntity<ErrorResponse> handleNotFoundException(NotFoundExceptio
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(ErrorResponse.of(e.getErrorMessage()));
}

@ExceptionHandler(CustomValidateException.class)
protected ResponseEntity<ErrorResponse> handleNotFoundException(CustomValidateException e) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(ErrorResponse.of(e.getErrorMessage()));
}

}

0 comments on commit beda91d

Please sign in to comment.