Add error handling for missing match ids
This commit is contained in:
@@ -146,9 +146,13 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
||||
ArrayList<APIFootballMatch> missingMatches = new ArrayList<>();
|
||||
|
||||
for(APIFootballMatch apiFootballMatch : apiFootballMatches) {
|
||||
try {
|
||||
if(getMatchingMatch(apiFootballMatch, tlwMatches) == null) {
|
||||
missingMatches.add(apiFootballMatch);
|
||||
}
|
||||
} catch (NullPointerException ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for (APIFootballMatch missingMatch : missingMatches) {
|
||||
@@ -171,12 +175,16 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
||||
ArrayList<APIFootballMatch> apiFootballMatches)
|
||||
{
|
||||
for(APIFootballMatch apiFootballMatch : apiFootballMatches) {
|
||||
try {
|
||||
TLWMatch tlwMatch = getMatchingMatch(apiFootballMatch, tlwMatches);
|
||||
if(tlwMatch == null) {
|
||||
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) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,12 +208,16 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
||||
ArrayList<APIFootballMatch> apiFootballMatches)
|
||||
{
|
||||
for(APIFootballMatch apiFootballMatch : apiFootballMatches) {
|
||||
try {
|
||||
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;
|
||||
TLWMatch matchingMatch = null;
|
||||
for(TLWMatch match : tlwMatches) {
|
||||
|
||||
Reference in New Issue
Block a user