Pu Zhibing
5 天以前 f2530067b6cd16a87b76190cf524d2ed75bf9592
management/guns-admin/src/main/java/com/stylefeng/guns/core/aop/GlobalExceptionHandler.java
@@ -1,5 +1,6 @@
package com.stylefeng.guns.core.aop;
import com.stylefeng.guns.core.beetl.ShiroExtUtil;
import com.stylefeng.guns.core.common.exception.BizExceptionEnum;
import com.stylefeng.guns.core.common.exception.InvalidKaptchaException;
import com.stylefeng.guns.core.base.tips.ErrorTip;
@@ -12,6 +13,7 @@
import org.apache.shiro.authc.DisabledAccountException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.ui.Model;
@@ -37,6 +39,9 @@
    private Logger log = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private ShiroExtUtil shiroExtUtil;
    /**
     * 拦截业务异常
     */
@@ -44,7 +49,7 @@
    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    @ResponseBody
    public ErrorTip notFount(GunsException e) {
        LogManager.me().executeLog(LogTaskFactory.exceptionLog(ShiroKit.getUser().getId(), e));
        LogManager.me().executeLog(LogTaskFactory.exceptionLog(shiroExtUtil.getUser().getId(), e));
        getRequest().setAttribute("tip", e.getMessage());
        log.error("业务异常:", e);
        return new ErrorTip(e.getCode(), e.getMessage());
@@ -115,7 +120,7 @@
    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    @ResponseBody
    public ErrorTip notFount(RuntimeException e) {
        LogManager.me().executeLog(LogTaskFactory.exceptionLog(ShiroKit.getUser().getId(), e));
        LogManager.me().executeLog(LogTaskFactory.exceptionLog(shiroExtUtil.getUser().getId(), e));
        getRequest().setAttribute("tip", "服务器未知运行时异常");
        log.error("运行时异常:", e);
        return new ErrorTip(BizExceptionEnum.SERVER_ERROR.getCode(), BizExceptionEnum.SERVER_ERROR.getMessage());