Commit d5103c594717e71a0ef5ecb3491fa1dce0293403
1 parent
f9eb99cd
HTTP接口调用异常报错信息为null修复
Signed-off-by: TanYibin <5491541@qq.com>
Showing
1 changed file
with
11 additions
and
10 deletions
huaheng-wms-core/src/main/java/org/jeecg/utils/OkHttpUtils.java
... | ... | @@ -112,18 +112,18 @@ public class OkHttpUtils { |
112 | 112 | response = HTTP_CLIENT.newCall(request).execute(); |
113 | 113 | result = response.body().string(); |
114 | 114 | } catch (Exception e) { |
115 | - log.error("执行GET请求异常,url:{},header:{},param:{},errorMessage:{}", url, JSON.toJSONString(headers), param, ExceptionUtil.getMessage(e), e); | |
115 | + String errorString = StrUtil.format("执行GET请求异常,url: {},{}", url, ExceptionUtil.getMessage(e)); | |
116 | + log.error(errorString, e); | |
116 | 117 | ApiLoggerAspect.setApiLogException(apiLog, e); |
117 | - throw ExceptionUtil.convertFromOrSuppressedThrowable(e, JeecgBootException.class); | |
118 | + throw new JeecgBootException(errorString, e); | |
118 | 119 | } finally { |
119 | 120 | ApiLoggerAspect.finishApiLog(apiLog, response, result); |
120 | 121 | } |
121 | 122 | // 调用成功 |
122 | 123 | if (response.isSuccessful() && Objects.nonNull(response.body())) { |
123 | - log.info("执行GET请求成功,url:{},header:{},param:{},result:{}", url, JSON.toJSONString(headers), param, result); | |
124 | + log.info("执行GET请求成功,url: {},result: {}", url, result); | |
124 | 125 | } else { |
125 | - throw new JeecgBootException(StrUtil.format("执行GET请求失败,url:{},header:{},param:{},responseCode:{},responseMessage:{}", url, JSON.toJSONString(headers), | |
126 | - param, response.code(), response.message())); | |
126 | + throw new JeecgBootException(StrUtil.format("执行GET请求失败,url: {},responseCode: {},responseMessage: {}", url, response.code(), response.message())); | |
127 | 127 | } |
128 | 128 | return result; |
129 | 129 | } |
... | ... | @@ -152,18 +152,19 @@ public class OkHttpUtils { |
152 | 152 | response = HTTP_CLIENT.newCall(request).execute(); |
153 | 153 | result = response.body().string(); |
154 | 154 | } catch (Exception e) { |
155 | - log.error("执行POST请求异常,url:{},header:{},param:{},errorMessage:{}", url, JSON.toJSONString(headers), jsonString, ExceptionUtil.getMessage(e), e); | |
155 | + String errorString = StrUtil.format("执行POST请求异常,url: {},{}", url, ExceptionUtil.getMessage(e)); | |
156 | + log.error(errorString, e); | |
156 | 157 | ApiLoggerAspect.setApiLogException(apiLog, e); |
157 | - throw ExceptionUtil.convertFromOrSuppressedThrowable(e, JeecgBootException.class); | |
158 | + throw new JeecgBootException(errorString, e); | |
158 | 159 | } finally { |
159 | 160 | ApiLoggerAspect.finishApiLog(apiLog, response, result); |
160 | 161 | } |
161 | 162 | // 调用成功 |
162 | 163 | if (response.isSuccessful() && Objects.nonNull(response.body())) { |
163 | - log.info("执行POST请求成功,url:{},header:{},param:{},result:{}", url, JSON.toJSONString(headers), jsonString, result); | |
164 | + log.info("执行POST请求成功,url: {},result: {}", url, result); | |
164 | 165 | } else { |
165 | - throw new JeecgBootException(StrUtil.format("执行POST请求失败,url:{},header:{},param:{},responseCode:{},responseMessage:{}", url, JSON.toJSONString(headers), | |
166 | - jsonString, response.code(), response.message())); | |
166 | + throw new JeecgBootException(StrUtil.format("执行POST请求失败,url: {},responseCode: {},responseMessage: {}", url, JSON.toJSONString(headers), jsonString, | |
167 | + response.code(), response.message())); | |
167 | 168 | } |
168 | 169 | return result; |
169 | 170 | } |
... | ... |