Skip to content

Commit 1dd3e6c

Browse files
author
Tom Whipple
committed
fix crash when error body is null (e.g. on connection failure)
1 parent 797b3b8 commit 1dd3e6c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/com/loopj/android/http/JsonHttpResponseHandler.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,19 @@ public void onFailure(Throwable e, JSONArray errorResponse) {}
8888
@Override
8989
protected void handleFailureMessage(Throwable e, String responseBody) {
9090
super.handleFailureMessage(e, responseBody);
91-
try {
91+
if (responseBody != null) try {
9292
Object jsonResponse = parseResponse(responseBody);
9393
if(jsonResponse instanceof JSONObject) {
9494
onFailure(e, (JSONObject)jsonResponse);
9595
} else if(jsonResponse instanceof JSONArray) {
9696
onFailure(e, (JSONArray)jsonResponse);
9797
}
98-
} catch(JSONException ex) {
98+
}
99+
catch(JSONException ex) {
99100
onFailure(e, responseBody);
100101
}
102+
else {
103+
onFailure(e, "");
104+
}
101105
}
102106
}

0 commit comments

Comments
 (0)