Skip to content
This repository was archived by the owner on Jul 26, 2019. It is now read-only.

Commit 73b4412

Browse files
committed
Fixing error when BotBlock doesn't have a failure object
1 parent 09275ee commit 73b4412

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins{
77
}
88

99
group = 'com.andre601'
10-
version = '1.0.2'
10+
version = '1.0.3'
1111

1212
sourceCompatibility = 1.8
1313

src/main/java/com/andre601/javabotblockapi/RequestHandler.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -216,22 +216,22 @@ private void performRequest() throws IOException, RatelimitedException{
216216
));
217217
}
218218

219-
JSONObject responseJson = new JSONObject(response.body());
220-
if(!responseJson.get("failure").equals("[]")){
221-
JSONObject failures = responseJson.getJSONObject("failure");
219+
JSONObject json = new JSONObject(response.body());
220+
if(json.has("failure")){
221+
JSONObject failure = json.getJSONObject("failure");
222222

223223
List<String> sites = new ArrayList<>();
224-
for(String key : failures.keySet()){
224+
for (String key : failure.keySet()) {
225225
try {
226-
JSONArray array = failures.getJSONArray(key);
226+
JSONArray array = failure.getJSONArray(key);
227227
sites.add(String.format(
228228
"Name: %s, Error code: %d, Error Message: %s",
229229
key,
230230
array.getInt(0),
231231
array.getString(1)
232232
));
233-
}catch(JSONException ex){
234-
Map<String, Object> notFound = failures.toMap();
233+
} catch (JSONException ex) {
234+
Map<String, Object> notFound = failure.toMap();
235235
sites.add("Errors: " + notFound.toString());
236236
}
237237
}

0 commit comments

Comments
 (0)