Skip to content

Commit 364b0aa

Browse files
committed
完善 Exception 信息
1 parent 1127a2e commit 364b0aa

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/main/java/com/qcloud/image/http/DefaultImageHttpClient.java

+16-2
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,14 @@ protected String sendPostRequest(HttpRequest httpRequest) throws AbstractImageEx
163163
throw new ServerException(e.getMessage());
164164
}
165165
if (!response.isSuccessful()) {
166-
throw new ServerException("Unexpected code " + response);
166+
String string = null;
167+
try {
168+
string = response.body().string();
169+
} catch (IOException e) {
170+
throw new ServerException(e.getMessage());
171+
}
172+
String msg = String.format("Unexpected response: %s, content: %s", response, string);
173+
throw new ServerException(msg);
167174
}
168175

169176
String string = null;
@@ -206,7 +213,14 @@ protected String sendPostRequest(HttpRequest httpRequest) throws AbstractImageEx
206213
throw new ServerException(e.getMessage());
207214
}
208215
if (!response.isSuccessful()) {
209-
throw new ServerException("Unexpected code " + response);
216+
String string = null;
217+
try {
218+
string = response.body().string();
219+
} catch (IOException e) {
220+
throw new ServerException(e.getMessage());
221+
}
222+
String msg = String.format("Unexpected response: %s, content: %s", response, string);
223+
throw new ServerException(msg);
210224
}
211225
String string = null;
212226
try {

0 commit comments

Comments
 (0)