From 1845fe7a4d8c435e8f17b1c6f823d313b2b1321c Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 1 Jun 2019 13:17:32 +0200 Subject: [PATCH] Filter/clarify exceptions --- .../main/java/eu/faircode/email/ApplicationEx.java | 4 ++-- app/src/main/java/eu/faircode/email/Core.java | 4 +++- .../main/java/eu/faircode/email/MessageHelper.java | 12 ++++++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ApplicationEx.java b/app/src/main/java/eu/faircode/email/ApplicationEx.java index 8f5bbbbdb9..2c7caad283 100644 --- a/app/src/main/java/eu/faircode/email/ApplicationEx.java +++ b/app/src/main/java/eu/faircode/email/ApplicationEx.java @@ -170,7 +170,7 @@ public class ApplicationEx extends Application { ignore.add("java.net.ConnectException"); ignore.add("java.net.SocketTimeoutException"); ignore.add("java.net.SocketException"); - // android.accounts.OperationCanceledException + ignore.add("android.accounts.OperationCanceledException"); ignore.add("javax.mail.StoreClosedException"); ignore.add("javax.mail.FolderClosedException"); @@ -179,7 +179,7 @@ public class ApplicationEx extends Application { ignore.add("javax.mail.MessageRemovedException"); ignore.add("javax.mail.internet.AddressException"); - ignore.add("android.accounts.OperationCanceledException"); + ignore.add("java.nio.charset.MalformedInputException"); config.setIgnoreClasses(ignore.toArray(new String[0])); diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 706dd24cd9..f8ff6b0df3 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -1061,7 +1061,9 @@ class Core { } } else { for (Response response : responses) - if (response.isNO() || response.isBAD() || response.isBYE()) + if (response.isBYE()) + return new MessagingException("UID FETCH", new IOException(response.toString())); + else if (response.isNO() || response.isBAD()) return new MessagingException(response.toString()); return new MessagingException("UID FETCH failed"); } diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index fd8922ace6..ae028f2bfe 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -601,11 +601,15 @@ public class MessageHelper { return null; // https://www.ietf.org/rfc/rfc2368.txt - MailTo to = MailTo.parse(list.substring(1, list.length() - 1)); - if (to.getTo() == null) - return null; + try { + MailTo to = MailTo.parse(list.substring(1, list.length() - 1)); + if (to.getTo() == null) + return null; - return new Address[]{new InternetAddress(to.getTo().split(",")[0])}; + return new Address[]{new InternetAddress(to.getTo().split(",")[0])}; + } catch (android.net.ParseException ex) { + throw new ParseException(list); + } } catch (android.net.ParseException ex) { Log.w(ex); return null;