From 458d61034f3373a31bb83b830a353fd14a28930c Mon Sep 17 00:00:00 2001 From: Gyubin-Han Date: Wed, 18 Jun 2025 01:21:35 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20=EB=8B=A8=EC=B6=95=20URL=20=EB=AF=B8?= =?UTF-8?q?=EC=A1=B4=EC=9E=AC=20=EC=8B=9C=20=EB=B0=9C=EC=83=9D=ED=95=98?= =?UTF-8?q?=EB=8A=94=20Exception=20Handling=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../advice/ExceptionHandlerAdvice.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/main/java/be/gyu/urlShortener/advice/ExceptionHandlerAdvice.java diff --git a/src/main/java/be/gyu/urlShortener/advice/ExceptionHandlerAdvice.java b/src/main/java/be/gyu/urlShortener/advice/ExceptionHandlerAdvice.java new file mode 100644 index 0000000..5ddd1e1 --- /dev/null +++ b/src/main/java/be/gyu/urlShortener/advice/ExceptionHandlerAdvice.java @@ -0,0 +1,16 @@ +package be.gyu.urlShortener.advice; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; + +import be.gyu.urlShortener.exception.ShortUrlNotFoundException; +import jakarta.servlet.http.HttpServletResponse; + +@ControllerAdvice(basePackages={"be.gyu.urlShortener.controller"}) +public class ExceptionHandlerAdvice { + @ExceptionHandler(ShortUrlNotFoundException.class) + public void ShortUrlNotFoundExceptionHandler(HttpServletResponse response){ + response.setStatus(HttpStatus.NOT_FOUND.value()); + } +}