From 022b17044ab6bb284fd6313da91d1d1dfb2d5079 Mon Sep 17 00:00:00 2001
From: kongzy <kongzy>
Date: 星期一, 03 六月 2024 13:20:42 +0800
Subject: [PATCH] update

---
 assess-framework/src/main/java/com/gkhy/assess/framework/exception/GlobalExceptionHandler.java |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/assess-framework/src/main/java/com/gkhy/assess/framework/exception/GlobalExceptionHandler.java b/assess-framework/src/main/java/com/gkhy/assess/framework/exception/GlobalExceptionHandler.java
index 6d6083b..a92ec25 100644
--- a/assess-framework/src/main/java/com/gkhy/assess/framework/exception/GlobalExceptionHandler.java
+++ b/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);
     }
 }

--
Gitblit v1.9.2