Skip to content

Commit c0845f6

Browse files
committed
Merge pull request #30 from christianekstrand/master
Fix for NullPointerException seen in production environment. Overly caut...
2 parents 36a8e2e + 66eecf8 commit c0845f6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

intercom-java/src/main/java/io/intercom/api/IntercomException.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,21 @@ public IntercomException(String message, Throwable cause) {
1616
}
1717

1818
public IntercomException(ErrorCollection errorCollection) {
19-
this(errorCollection.getErrors().get(0).getMessage());
19+
this(getMessage(errorCollection));
2020
this.errorCollection = errorCollection;
2121
}
2222

23+
public static String getMessage(ErrorCollection errorCollection) {
24+
String message = "";
25+
if(errorCollection!=null && errorCollection.getErrors() != null && errorCollection.getErrors().size() > 0 && errorCollection.getErrors().get(0) != null){
26+
message = errorCollection.getErrors().get(0).getMessage();
27+
}
28+
return message;
29+
}
30+
2331
@SuppressWarnings("WeakerAccess")
2432
public IntercomException(ErrorCollection errorCollection, Throwable cause) {
25-
this(errorCollection.getErrors().get(0).getMessage(), cause);
33+
this(getMessage(errorCollection), cause);
2634
this.errorCollection = errorCollection;
2735
}
2836

0 commit comments

Comments
 (0)