From 32cc97207c80214c34a4945317ce234840fafc3e Mon Sep 17 00:00:00 2001 From: Art O Cathain Date: Wed, 1 Jul 2015 16:57:13 +0100 Subject: [PATCH] do not throw exception in MessagingController per review comment --- .../java/com/fsck/k9/provider/MessageProvider.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/k9mail/src/main/java/com/fsck/k9/provider/MessageProvider.java b/k9mail/src/main/java/com/fsck/k9/provider/MessageProvider.java index 2bb404afa..14f483ff8 100644 --- a/k9mail/src/main/java/com/fsck/k9/provider/MessageProvider.java +++ b/k9mail/src/main/java/com/fsck/k9/provider/MessageProvider.java @@ -1035,7 +1035,7 @@ public class MessageProvider extends ContentProvider { } if (myAccount == null) { - throw new IllegalArgumentException("Could not find account with id " + accountId); + Log.e(K9.LOG_TAG, "Could not find account with id " + accountId); } // get localstore parameter @@ -1048,16 +1048,14 @@ public class MessageProvider extends ContentProvider { } msg = lf.getMessage(msgUid); } catch (MessagingException e) { - throw new RuntimeException(e); - } - - if (msg == null) { - throw new IllegalArgumentException("Could not find message with id " + msgUid); + Log.e(K9.LOG_TAG, "Unable to retrieve message", e); } // launch command to delete the message - MessagingController controller = MessagingController.getInstance(getContext()); - controller.deleteMessages(Collections.singletonList(msg), null); + if ((myAccount != null) && (msg != null)) { + MessagingController controller = MessagingController.getInstance(getContext()); + controller.deleteMessages(Collections.singletonList(msg), null); + } // FIXME return the actual number of deleted messages return 0;