Check for null FCM error codes

This commit is contained in:
Jon Chambers 2022-08-02 17:20:01 -04:00 committed by Jon Chambers
parent c9ae991aa3
commit 8956e1e0cf
1 changed files with 10 additions and 1 deletions

View File

@ -87,7 +87,16 @@ public class FcmSender {
sendFuture.get();
} catch (ExecutionException e) {
if (e.getCause() instanceof final FirebaseMessagingException firebaseMessagingException) {
tags = tags.and("errorCode", firebaseMessagingException.getMessagingErrorCode().name().toLowerCase());
final String errorCode;
if (firebaseMessagingException.getMessagingErrorCode() != null) {
errorCode = firebaseMessagingException.getMessagingErrorCode().name().toLowerCase();
} else {
logger.warn("Received an FCM exception with no error code", firebaseMessagingException);
errorCode = "unknown";
}
tags = tags.and("errorCode", errorCode);
switch (firebaseMessagingException.getMessagingErrorCode()) {