Skip to content

Commit

Permalink
Exception handling
Browse files Browse the repository at this point in the history
Fixed a crash that would occur when valid json was not given by the api
  • Loading branch information
BullShark authored and CreativeCodeCat committed Oct 10, 2021
1 parent b6f4dbd commit ae1a828
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/jrobo/Leet.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonSyntaxException;
import java.io.IOException;
import java.net.URI;
import java.util.Arrays;
Expand Down Expand Up @@ -237,9 +238,10 @@ public String getFormattedResult(final boolean HAS_COLORS) {
gson = new GsonBuilder().setPrettyPrinting().create();
RESULTS = gson.fromJson(this.getJson(), LeetJsonItem[].class);

} catch (IllegalStateException | NullPointerException ex) {
} catch (IllegalStateException | NullPointerException | JsonSyntaxException ex) {
Logger.getLogger(Leet.class.getName()).log(Level.SEVERE, null, ex);
return "";
json = "{ \"data\": \"Unable to retrieve Torrent json data\" }";
return json;
}

String output = "";
Expand Down

0 comments on commit ae1a828

Please sign in to comment.