From 7af1dd6a3b5cc82e67d05b794ce03b7765129c7b Mon Sep 17 00:00:00 2001 From: Parkseojin Date: Wed, 1 May 2024 18:44:24 +0900 Subject: [PATCH] =?UTF-8?q?add=20:=203=EC=B0=A8=20=EC=84=B8=EB=AF=B8?= =?UTF-8?q?=EB=82=98=20=EC=8B=A4=EC=8A=B5=20=EA=B3=BC=EC=A0=9C=5F=20?= =?UTF-8?q?=EC=BB=A4=EC=8A=A4=ED=85=80=20Exception=20ValidateException=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20#7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/example/demo/exception/ValidateException.java | 11 +++++++++++ .../java/com/example/demo/service/BlogService.java | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 week02/seminar/demo/src/main/java/com/example/demo/exception/ValidateException.java diff --git a/week02/seminar/demo/src/main/java/com/example/demo/exception/ValidateException.java b/week02/seminar/demo/src/main/java/com/example/demo/exception/ValidateException.java new file mode 100644 index 0000000..6a6ae96 --- /dev/null +++ b/week02/seminar/demo/src/main/java/com/example/demo/exception/ValidateException.java @@ -0,0 +1,11 @@ +package com.example.demo.exception; + +import com.example.demo.common.dto.ErrorMessage; + +public class ValidateException extends BusinessException { + + public ValidateException(ErrorMessage errorMessage) { + super(errorMessage); + } + +} diff --git a/week02/seminar/demo/src/main/java/com/example/demo/service/BlogService.java b/week02/seminar/demo/src/main/java/com/example/demo/service/BlogService.java index 1abcd04..047729b 100644 --- a/week02/seminar/demo/src/main/java/com/example/demo/service/BlogService.java +++ b/week02/seminar/demo/src/main/java/com/example/demo/service/BlogService.java @@ -4,6 +4,7 @@ import com.example.demo.domain.Blog; import com.example.demo.domain.Member; import com.example.demo.exception.NotFoundException; +import com.example.demo.exception.ValidateException; import com.example.demo.repository.BlogRepository; import com.example.demo.service.dto.blog.BlogCreateRequest; import com.example.demo.service.dto.blog.BlogTitleUpdateRequest; @@ -40,7 +41,7 @@ public void updateTitle(Long blogId, BlogTitleUpdateRequest blogTitleUpdateReque public void validateOwner(Long requestMemberId, Long findMemberId) { if (!requestMemberId.equals(findMemberId)) { - throw new NotFoundException(ErrorMessage.BLOG_UNAUTHORIZED); + throw new ValidateException(ErrorMessage.BLOG_UNAUTHORIZED); } } }