From 412ebca2166e13c9d1810756ce02f972fdb9e56f Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 27 Jul 2021 21:04:48 +0200 Subject: [PATCH] Improved error reporting --- app/src/main/java/eu/faircode/email/Core.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index ca0e19f78f..9594c1e7ed 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -2269,7 +2269,7 @@ class Core { private static void onSynchronizeMessages( Context context, JSONArray jargs, EntityAccount account, final EntityFolder folder, - POP3Folder ifolder, POP3Store istore, State state) throws Throwable { + POP3Folder ifolder, POP3Store istore, State state) throws MessagingException, IOException { DB db = DB.getInstance(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean notify_known = prefs.getBoolean("notify_known", false); @@ -2582,7 +2582,7 @@ class Core { private static void onSynchronizeMessages( Context context, JSONArray jargs, EntityAccount account, final EntityFolder folder, - IMAPStore istore, final IMAPFolder ifolder, State state) throws Throwable { + IMAPStore istore, final IMAPFolder ifolder, State state) throws JSONException, MessagingException, IOException { final DB db = DB.getInstance(context); try { SyncStats stats = new SyncStats(); @@ -4989,9 +4989,9 @@ class Core { join(thread); } - void ensureRunning(String reason) throws Throwable { + void ensureRunning(String reason) { if (!recoverable && unrecoverable != null) - throw unrecoverable; + throw new OperationCanceledExceptionEx(reason, unrecoverable); if (!running) throw new OperationCanceledException(reason); } @@ -5122,6 +5122,21 @@ class Core { } } + static class OperationCanceledExceptionEx extends OperationCanceledException { + private Throwable cause; + + OperationCanceledExceptionEx(String message, Throwable cause) { + super(message); + this.cause = cause; + } + + @Nullable + @Override + public Throwable getCause() { + return this.cause; + } + } + private static class SyncStats { long search_ms; int flags;