diff --git a/luoo_tag/src/main/java/com/luoo/tag/controller/BaseExceptionHandler.java b/luoo_tag/src/main/java/com/luoo/tag/controller/BaseExceptionHandler.java index 9ed0ff9..e0e0ebb 100644 --- a/luoo_tag/src/main/java/com/luoo/tag/controller/BaseExceptionHandler.java +++ b/luoo_tag/src/main/java/com/luoo/tag/controller/BaseExceptionHandler.java @@ -1,22 +1,30 @@ package com.luoo.tag.controller; + +import com.luoo.common.exception.BizException; import entity.Result; import entity.StatusCode; +import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; /** * 统一异常处理类 */ +@Slf4j @ControllerAdvice public class BaseExceptionHandler { @ExceptionHandler(value = Exception.class) @ResponseBody public Result error(Exception e){ - e.printStackTrace(); + log.error("执行出错", e); return new Result(false, StatusCode.ERROR, "执行出错"); } + + @ExceptionHandler(value = BizException.class) + @ResponseBody + public Result error(BizException e){ + log.info("业务错误", e); + return new Result(false, StatusCode.ERROR, "业务错误"); + } }