Improve error handling

This commit is contained in:
2021-01-10 22:22:49 +01:00
parent 4bd7af39a8
commit 50ba1198c7
2 changed files with 8 additions and 4 deletions

View File

@@ -73,8 +73,8 @@ public class APIFootballConnector {
try { try {
APIFootballMatch match = new APIFootballMatch((JSONObject) matchArray.get(i), this.season); APIFootballMatch match = new APIFootballMatch((JSONObject) matchArray.get(i), this.season);
matchesList.add(match); matchesList.add(match);
} catch (NullPointerException e) { } catch (Exception e) {
logger.error("Could not create config for match: " + matchArray.get(i).toString()); logger.error(e.getMessage());
} }
} }

View File

@@ -12,7 +12,7 @@ public class APIFootballMatch extends BaseMatch {
private final String teamNameGuest; private final String teamNameGuest;
private Boolean showTable = null; private Boolean showTable = null;
public APIFootballMatch(JSONObject json, int season) { public APIFootballMatch(JSONObject json, int season) throws Exception {
this.matchId = Integer.parseInt(json.get("fixture_id").toString()); this.matchId = Integer.parseInt(json.get("fixture_id").toString());
// TODO // TODO
this.leagueId = Integer.parseInt(json.get("league_id").toString()); this.leagueId = Integer.parseInt(json.get("league_id").toString());
@@ -22,7 +22,11 @@ public class APIFootballMatch extends BaseMatch {
this.teamNameGuest = ((JSONObject) json.get("awayTeam")).get("team_name").toString(); this.teamNameGuest = ((JSONObject) json.get("awayTeam")).get("team_name").toString();
this.goalsHome = getNumberOrNull(json.get("goalsHomeTeam")); this.goalsHome = getNumberOrNull(json.get("goalsHomeTeam"));
this.goalsGuest = getNumberOrNull(json.get("goalsAwayTeam")); this.goalsGuest = getNumberOrNull(json.get("goalsAwayTeam"));
this.matchday = getMatchdayFromRoundString(season, json.get("round").toString(), this.leagueId); try {
this.matchday = getMatchdayFromRoundString(season, json.get("round").toString(), this.leagueId);
} catch (Exception e) {
throw new Exception("Did not find matchday for league '" + this.leagueId + "': '" + json.get("round").toString() + "'");
}
this.matchDatetime = (String) json.get("event_date"); this.matchDatetime = (String) json.get("event_date");
} }