Add error handling for missing match ids

This commit is contained in:
2021-01-10 20:38:26 +01:00
parent 87c0383db8
commit 27193999fc

View File

@@ -146,8 +146,12 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
ArrayList<APIFootballMatch> missingMatches = new ArrayList<>(); ArrayList<APIFootballMatch> missingMatches = new ArrayList<>();
for(APIFootballMatch apiFootballMatch : apiFootballMatches) { for(APIFootballMatch apiFootballMatch : apiFootballMatches) {
if(getMatchingMatch(apiFootballMatch, tlwMatches) == null) { try {
missingMatches.add(apiFootballMatch); if(getMatchingMatch(apiFootballMatch, tlwMatches) == null) {
missingMatches.add(apiFootballMatch);
}
} catch (NullPointerException ignored) {
} }
} }
@@ -171,12 +175,16 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
ArrayList<APIFootballMatch> apiFootballMatches) ArrayList<APIFootballMatch> apiFootballMatches)
{ {
for(APIFootballMatch apiFootballMatch : apiFootballMatches) { for(APIFootballMatch apiFootballMatch : apiFootballMatches) {
TLWMatch tlwMatch = getMatchingMatch(apiFootballMatch, tlwMatches); try {
if(tlwMatch == null) { TLWMatch tlwMatch = getMatchingMatch(apiFootballMatch, tlwMatches);
StatusHolder.setError(); if(tlwMatch == null) {
logger.error("Did not find match to update: " + this.season + ", " + this.league + ", " + tlwMatches.get(0).getMatchday() + ", " + apiFootballMatch.getTeamNameHome() + " - " + apiFootballMatch.getTeamNameGuest()); StatusHolder.setError();
logger.error("Did not find match to update: " + this.season + ", " + this.league + ", " + tlwMatches.get(0).getMatchday() + ", " + apiFootballMatch.getTeamNameHome() + " - " + apiFootballMatch.getTeamNameGuest());
}
tlwMatch.setMatchDateTime(apiFootballMatch.getMatchDateTime().replace("T", " ").substring(0, 19));
} catch(NullPointerException ignored) {
} }
tlwMatch.setMatchDateTime(apiFootballMatch.getMatchDateTime().replace("T", " ").substring(0, 19));
} }
} }
@@ -200,12 +208,16 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
ArrayList<APIFootballMatch> apiFootballMatches) ArrayList<APIFootballMatch> apiFootballMatches)
{ {
for(APIFootballMatch apiFootballMatch : apiFootballMatches) { for(APIFootballMatch apiFootballMatch : apiFootballMatches) {
TLWMatch tlwMatch = getMatchingMatch(apiFootballMatch, tlwMatches); try {
tlwMatch.setShowTable(apiFootballMatch.getShowTable()); TLWMatch tlwMatch = getMatchingMatch(apiFootballMatch, tlwMatches);
tlwMatch.setShowTable(apiFootballMatch.getShowTable());
} catch (NullPointerException ignored) {
}
} }
} }
private TLWMatch getMatchingMatch(APIFootballMatch apiFootballMatch, ArrayList<TLWMatch> tlwMatches) { private TLWMatch getMatchingMatch(APIFootballMatch apiFootballMatch, ArrayList<TLWMatch> tlwMatches) throws NullPointerException{
int foundMatches = 0; int foundMatches = 0;
TLWMatch matchingMatch = null; TLWMatch matchingMatch = null;
for(TLWMatch match : tlwMatches) { for(TLWMatch match : tlwMatches) {