Skip to content

Commit

Permalink
🐛 guard against NPE when error checking
Browse files Browse the repository at this point in the history
  • Loading branch information
ebullient committed Jun 8, 2024
1 parent b4eb7d4 commit 394a140
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,13 @@ public Throwable bundleExceptions() {

public boolean hasNotFound() {
return exceptions.stream().anyMatch(e -> e instanceof GHFileNotFoundException)
|| errors.stream().anyMatch(e -> e.getOtherFields().containsKey("type")
&& e.getOtherFields().get("type").equals("NOT_FOUND"));
|| errors.stream().anyMatch(e -> hasFieldError(e, "NOT_FOUND"));
}

private boolean hasFieldError(GraphQLError e, String message) {
var others = e.getOtherFields();
var type = others == null ? null : others.get("type");
return message.equals(type);
}

public boolean clearNotFound() {
Expand Down

0 comments on commit 394a140

Please sign in to comment.