package cn.reghao.autodop.dmaster.spring.exception;

import lombok.extern.slf4j.Slf4j;

/**
 * 处理 Filter 中重定向的错误
 * BasicErrorController 实现了 ErrorController
 *
 * @author reghao
 * @date 2019/03/21 10:17:05
 */
@Slf4j
//@RestController
public class WebErrorController /*implements ErrorController */{
    /*public MyErrorController() {
    }

    @RequestMapping("/error")
    public String handleError(Model model, HttpServletRequest request) {
        Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code");
        if (statusCode == 404) {
            return "接口不存在";
        } else if (statusCode == 400) {
            return "参数错误";
        } else if (statusCode == 500) {
            return "服务器内部错误";
        }
        log.error("http status code: " + statusCode);

        model.addAttribute("statusCode", statusCode);
        model.addAttribute("msg", "页面去火星啦～");
        return "/404";
    }

    @Override
    public String getErrorPath() {
        return "/error";
    }*/
}
