From d5103c594717e71a0ef5ecb3491fa1dce0293403 Mon Sep 17 00:00:00 2001
From: TanYibin <5491541@qq.com>
Date: Tue, 20 Jun 2023 08:56:09 +0800
Subject: [PATCH] HTTP接口调用异常报错信息为null修复

---
 huaheng-wms-core/src/main/java/org/jeecg/utils/OkHttpUtils.java | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/huaheng-wms-core/src/main/java/org/jeecg/utils/OkHttpUtils.java b/huaheng-wms-core/src/main/java/org/jeecg/utils/OkHttpUtils.java
index c71e201..4bf7af4 100644
--- a/huaheng-wms-core/src/main/java/org/jeecg/utils/OkHttpUtils.java
+++ b/huaheng-wms-core/src/main/java/org/jeecg/utils/OkHttpUtils.java
@@ -112,18 +112,18 @@ public class OkHttpUtils {
             response = HTTP_CLIENT.newCall(request).execute();
             result = response.body().string();
         } catch (Exception e) {
-            log.error("执行GET请求异常,url:{},header:{},param:{},errorMessage:{}", url, JSON.toJSONString(headers), param, ExceptionUtil.getMessage(e), e);
+            String errorString = StrUtil.format("执行GET请求异常,url: {},{}", url, ExceptionUtil.getMessage(e));
+            log.error(errorString, e);
             ApiLoggerAspect.setApiLogException(apiLog, e);
-            throw ExceptionUtil.convertFromOrSuppressedThrowable(e, JeecgBootException.class);
+            throw new JeecgBootException(errorString, e);
         } finally {
             ApiLoggerAspect.finishApiLog(apiLog, response, result);
         }
         // 调用成功
         if (response.isSuccessful() && Objects.nonNull(response.body())) {
-            log.info("执行GET请求成功,url:{},header:{},param:{},result:{}", url, JSON.toJSONString(headers), param, result);
+            log.info("执行GET请求成功,url: {},result: {}", url, result);
         } else {
-            throw new JeecgBootException(StrUtil.format("执行GET请求失败,url:{},header:{},param:{},responseCode:{},responseMessage:{}", url, JSON.toJSONString(headers),
-                param, response.code(), response.message()));
+            throw new JeecgBootException(StrUtil.format("执行GET请求失败,url: {},responseCode: {},responseMessage: {}", url, response.code(), response.message()));
         }
         return result;
     }
@@ -152,18 +152,19 @@ public class OkHttpUtils {
             response = HTTP_CLIENT.newCall(request).execute();
             result = response.body().string();
         } catch (Exception e) {
-            log.error("执行POST请求异常,url:{},header:{},param:{},errorMessage:{}", url, JSON.toJSONString(headers), jsonString, ExceptionUtil.getMessage(e), e);
+            String errorString = StrUtil.format("执行POST请求异常,url: {},{}", url, ExceptionUtil.getMessage(e));
+            log.error(errorString, e);
             ApiLoggerAspect.setApiLogException(apiLog, e);
-            throw ExceptionUtil.convertFromOrSuppressedThrowable(e, JeecgBootException.class);
+            throw new JeecgBootException(errorString, e);
         } finally {
             ApiLoggerAspect.finishApiLog(apiLog, response, result);
         }
         // 调用成功
         if (response.isSuccessful() && Objects.nonNull(response.body())) {
-            log.info("执行POST请求成功,url:{},header:{},param:{},result:{}", url, JSON.toJSONString(headers), jsonString, result);
+            log.info("执行POST请求成功,url: {},result: {}", url, result);
         } else {
-            throw new JeecgBootException(StrUtil.format("执行POST请求失败,url:{},header:{},param:{},responseCode:{},responseMessage:{}", url, JSON.toJSONString(headers),
-                jsonString, response.code(), response.message()));
+            throw new JeecgBootException(StrUtil.format("执行POST请求失败,url: {},responseCode: {},responseMessage: {}", url, JSON.toJSONString(headers), jsonString,
+                response.code(), response.message()));
         }
         return result;
     }
--
libgit2 0.22.2