kongzy
2024-06-03 022b17044ab6bb284fd6313da91d1d1dfb2d5079
assess-framework/src/main/java/com/gkhy/assess/framework/exception/GlobalExceptionHandler.java
@@ -4,6 +4,7 @@
import com.gkhy.assess.common.exception.ApiException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.UnauthorizedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -79,6 +80,16 @@
    /**
     * 拦截未知的运行时异常
     */
    @ExceptionHandler(UnauthorizedException.class)
    public CommonResult handleUnauthorizedException(RuntimeException ex, HttpServletRequest request)
    {
        writeExceptionLogFile(ex);
        return CommonResult.failed("权限不足,无权操作!");
    }
    /**
     * 拦截未知的运行时异常
     */
    @ExceptionHandler(RuntimeException.class)
    public CommonResult handleRuntimeException(RuntimeException ex, HttpServletRequest request)
    {
@@ -105,7 +116,7 @@
        if (request!=null) {
            url=request.getRequestURI();
        }
        log.error("error={}",ex);
        log.error("error:",ex);
        log.error(ex.getMessage()+",url={}",url);
    }
}