Improve error handling for getting matches
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package de.jeyp91.apifootball;
|
||||
|
||||
import de.jeyp91.S3Provider;
|
||||
import de.jeyp91.tippliga.TLWMatchesUpdaterFootball;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
@@ -14,6 +17,7 @@ public class APIFootballConnector {
|
||||
private final int season;
|
||||
private final HashMap<Integer, JSONObject> rounds = new HashMap<>();
|
||||
private final HashMap<Integer, JSONObject> matches = new HashMap<>();
|
||||
private static final Logger logger = LogManager.getLogger(APIFootballConnector.class);
|
||||
|
||||
private APIFootballConnector(int season) {
|
||||
this.season = season;
|
||||
@@ -66,7 +70,12 @@ public class APIFootballConnector {
|
||||
JSONArray matchArray = (JSONArray) (((JSONObject)matches.get("api")).get("fixtures"));
|
||||
|
||||
for(int i = 0; i < matchArray.size(); i++) {
|
||||
matchesList.add(new APIFootballMatch((JSONObject) matchArray.get(i), this.season));
|
||||
try {
|
||||
APIFootballMatch match = new APIFootballMatch((JSONObject) matchArray.get(i), this.season);
|
||||
matchesList.add(match);
|
||||
} catch (NullPointerException e) {
|
||||
logger.error("Could not create config for match: " + matchArray.get(i).toString());
|
||||
}
|
||||
}
|
||||
|
||||
return matchesList;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import de.jeyp91.App;
|
||||
import de.jeyp91.StatusHolder;
|
||||
import de.jeyp91.teamidmatcher.TeamIDMatcher;
|
||||
import de.jeyp91.apifootball.APIFootballMatch;
|
||||
|
||||
Reference in New Issue
Block a user