Skip to content

Commit

Permalink
回调Http状态码异常时,记录响应消息;
Browse files Browse the repository at this point in the history
  • Loading branch information
xuxueli committed Jul 14, 2017
1 parent 7b052d7 commit 5c0b206
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,13 @@ public static ReturnT<String> callApi(String finalUrl, Object requestObj) throws
HttpResponse response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
if (null != entity) {
String responseMsg = EntityUtils.toString(entity, "UTF-8");
if (response.getStatusLine().getStatusCode() != 200) {
EntityUtils.consume(entity);
return new ReturnT<String>(response.getStatusLine().getStatusCode(), "StatusCode Error.");
return new ReturnT<String>(response.getStatusLine().getStatusCode(),
"StatusCode(+"+ response.getStatusLine().getStatusCode() +") Error,response:" + responseMsg);
}

String responseMsg = EntityUtils.toString(entity, "UTF-8");
EntityUtils.consume(entity);
if (responseMsg!=null && responseMsg.startsWith("{")) {
ReturnT<String> result = JacksonUtil.readValue(responseMsg, ReturnT.class);
Expand Down

0 comments on commit 5c0b206

Please sign in to comment.