Mark as read - reduce scope of try/catch

NumberFormatException is expected only inside parseMessageId. To avoid masking other errors accidentally, seems better to have try/catch only around parseMessageId call.

Signed-off-by: Dariusz Olszewski <starypatyk@users.noreply.github.com>
This commit is contained in:
Dariusz Olszewski 2022-07-11 22:06:08 +02:00 committed by Marcel Hibbe (Rebase PR Action)
parent f5fce7c9c9
commit dafa1bfb2e

View File

@ -446,8 +446,13 @@ public class NotificationWorker extends Worker {
private void addMarkAsReadAction(NotificationCompat.Builder notificationBuilder, int systemNotificationId) { private void addMarkAsReadAction(NotificationCompat.Builder notificationBuilder, int systemNotificationId) {
if (decryptedPushMessage.getObjectId() != null) { if (decryptedPushMessage.getObjectId() != null) {
int messageId = 0;
try { try {
int messageId = parseMessageId(decryptedPushMessage.getObjectId()); messageId = parseMessageId(decryptedPushMessage.getObjectId());
} catch (NumberFormatException nfe) {
Log.e(TAG, "Failed to parse messageId from objectId, skip adding mark-as-read action.", nfe);
return;
}
// Build a PendingIntent for the mark as read action // Build a PendingIntent for the mark as read action
PendingIntent pendingIntent = buildIntentForAction(MarkAsReadReceiver.class, PendingIntent pendingIntent = buildIntentForAction(MarkAsReadReceiver.class,
@ -463,9 +468,6 @@ public class NotificationWorker extends Worker {
.build(); .build();
notificationBuilder.addAction(action); notificationBuilder.addAction(action);
} catch (NumberFormatException nfe) {
Log.e(TAG, "Failed to parse messageId from objectId, skip adding mark-as-read action.", nfe);
}
} }
} }