Browse Source

fixed 系统异常捕获

fushengqian 1 year ago
parent
commit
a7cc596588

+ 7 - 5
fuint-application/src/main/java/com/fuint/common/aspect/TActionLogAop.java

@@ -149,11 +149,13 @@ public class TActionLogAop {
             String token = request.getHeader("Access-Token");
             String token = request.getHeader("Access-Token");
             if (StringUtils.isNotEmpty(token)) {
             if (StringUtils.isNotEmpty(token)) {
                 AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
                 AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
-                userName = accountInfo.getAccountName();
-                merchantId = accountInfo.getMerchantId() == null ? 0 : accountInfo.getMerchantId();
-                storeId = accountInfo.getStoreId() == null ? 0 : accountInfo.getStoreId();
+                if (accountInfo != null) {
+                    userName = accountInfo.getAccountName();
+                    merchantId = accountInfo.getMerchantId() == null ? 0 : accountInfo.getMerchantId();
+                    storeId = accountInfo.getStoreId() == null ? 0 : accountInfo.getStoreId();
+                }
             } else {
             } else {
-                if (StringUtil.isNotEmpty(param)) {
+                if (StringUtil.isNotEmpty(param) && param.length() > 10) {
                     JSONObject jsonObject = JSON.parseObject(param);
                     JSONObject jsonObject = JSON.parseObject(param);
                     if (jsonObject != null) {
                     if (jsonObject != null) {
                         JSONObject tAccount = jsonObject.getJSONObject("tAccount");
                         JSONObject tAccount = jsonObject.getJSONObject("tAccount");
@@ -171,7 +173,7 @@ public class TActionLogAop {
             }
             }
             printOptLog();
             printOptLog();
         } catch (Exception e) {
         } catch (Exception e) {
-            logger.error("保存后台日志出错:{}", e.getMessage());
+            logger.error("保存后台日志出错:{}", e.getMessage());
             e.printStackTrace();
             e.printStackTrace();
         }
         }
     }
     }

+ 2 - 0
fuint-framework/src/main/java/com/fuint/framework/exception/GlobalExceptionHandler.java

@@ -69,6 +69,7 @@ public class GlobalExceptionHandler {
     public ResponseObject handleRuntimeException(RuntimeException e, HttpServletRequest request) {
     public ResponseObject handleRuntimeException(RuntimeException e, HttpServletRequest request) {
         String requestURI = request.getRequestURI();
         String requestURI = request.getRequestURI();
         log.error("请求地址'{}',发生未知异常.", requestURI, e);
         log.error("请求地址'{}',发生未知异常.", requestURI, e);
+        e.printStackTrace();
         return new ResponseObject(201, e.getMessage(), null);
         return new ResponseObject(201, e.getMessage(), null);
     }
     }
 
 
@@ -79,6 +80,7 @@ public class GlobalExceptionHandler {
     public ResponseObject handleException(Exception e, HttpServletRequest request) {
     public ResponseObject handleException(Exception e, HttpServletRequest request) {
         String requestURI = request.getRequestURI();
         String requestURI = request.getRequestURI();
         log.error("请求地址'{}',发生系统异常.", requestURI, e);
         log.error("请求地址'{}',发生系统异常.", requestURI, e);
+        e.printStackTrace();
         return new ResponseObject(201, e.getMessage(), null);
         return new ResponseObject(201, e.getMessage(), null);
     }
     }