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<>();
|
ArrayList<APIFootballMatch> missingMatches = new ArrayList<>();
|
||||||
|
|
||||||
for(APIFootballMatch apiFootballMatch : apiFootballMatches) {
|
for(APIFootballMatch apiFootballMatch : apiFootballMatches) {
|
||||||
|
try {
|
||||||
if(getMatchingMatch(apiFootballMatch, tlwMatches) == null) {
|
if(getMatchingMatch(apiFootballMatch, tlwMatches) == null) {
|
||||||
missingMatches.add(apiFootballMatch);
|
missingMatches.add(apiFootballMatch);
|
||||||
}
|
}
|
||||||
|
} catch (NullPointerException ignored) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (APIFootballMatch missingMatch : missingMatches) {
|
for (APIFootballMatch missingMatch : missingMatches) {
|
||||||
@@ -171,12 +175,16 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
|||||||
ArrayList<APIFootballMatch> apiFootballMatches)
|
ArrayList<APIFootballMatch> apiFootballMatches)
|
||||||
{
|
{
|
||||||
for(APIFootballMatch apiFootballMatch : apiFootballMatches) {
|
for(APIFootballMatch apiFootballMatch : apiFootballMatches) {
|
||||||
|
try {
|
||||||
TLWMatch tlwMatch = getMatchingMatch(apiFootballMatch, tlwMatches);
|
TLWMatch tlwMatch = getMatchingMatch(apiFootballMatch, tlwMatches);
|
||||||
if(tlwMatch == null) {
|
if(tlwMatch == null) {
|
||||||
StatusHolder.setError();
|
StatusHolder.setError();
|
||||||
logger.error("Did not find match to update: " + this.season + ", " + this.league + ", " + tlwMatches.get(0).getMatchday() + ", " + apiFootballMatch.getTeamNameHome() + " - " + apiFootballMatch.getTeamNameGuest());
|
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));
|
tlwMatch.setMatchDateTime(apiFootballMatch.getMatchDateTime().replace("T", " ").substring(0, 19));
|
||||||
|
} catch(NullPointerException ignored) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,12 +208,16 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
|||||||
ArrayList<APIFootballMatch> apiFootballMatches)
|
ArrayList<APIFootballMatch> apiFootballMatches)
|
||||||
{
|
{
|
||||||
for(APIFootballMatch apiFootballMatch : apiFootballMatches) {
|
for(APIFootballMatch apiFootballMatch : apiFootballMatches) {
|
||||||
|
try {
|
||||||
TLWMatch tlwMatch = getMatchingMatch(apiFootballMatch, tlwMatches);
|
TLWMatch tlwMatch = getMatchingMatch(apiFootballMatch, tlwMatches);
|
||||||
tlwMatch.setShowTable(apiFootballMatch.getShowTable());
|
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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user