package com.samsung.common.handler;

import lombok.extern.log4j.Log4j2;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.NoHandlerFoundException;

import jakarta.servlet.http.HttpServletRequest;

@Order(Ordered.HIGHEST_PRECEDENCE)
@ControllerAdvice
@Log4j2
public class NoHandleExceptionHandler {
    @ExceptionHandler(NoHandlerFoundException.class)
    public String handleException(HttpServletRequest request, Exception ex) {
        return "forward:/index.html?redirect=" + request.getRequestURI();
    }
}