Feat: 단축 URL 미존재 시 발생하는 Exception Handling 구현

This commit is contained in:
Gyubin-Han
2025-06-18 01:21:35 +09:00
parent 63808870f8
commit 458d61034f

View File

@@ -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());
}
}