From 1d97c9096837cb400af3ef481a8d9796ba6ac3c2 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 4 Aug 2018 14:41:10 +0000 Subject: [PATCH] Always catch exceptions --- .../main/java/eu/faircode/email/FragmentCompose.java | 7 ++++--- .../main/java/eu/faircode/email/FragmentMessages.java | 10 ++++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index b57c02cf..86c4032b 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -541,10 +541,11 @@ public class FragmentCompose extends Fragment { @Override public Throwable loadInBackground() { - long id = args.getLong("id"); - boolean send = args.getBoolean("send", false); - Log.i(Helper.TAG, "Put load id=" + id + " send=" + send); try { + long id = args.getLong("id"); + boolean send = args.getBoolean("send", false); + Log.i(Helper.TAG, "Put load id=" + id + " send=" + send); + DB db = DB.getInstance(getContext()); DaoMessage message = db.message(); DaoIdentity identity = db.identity(); diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 8025d5de..b29c218f 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -35,6 +35,7 @@ import android.support.v4.content.Loader; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -166,8 +167,13 @@ public class FragmentMessages extends Fragment { @Override public Bundle loadInBackground() { Bundle result = new Bundle(); - EntityFolder drafts = DB.getInstance(getContext()).folder().getPrimaryDraftFolder(); - result.putBoolean("drafts", drafts != null); + try { + EntityFolder drafts = DB.getInstance(getContext()).folder().getPrimaryDraftFolder(); + result.putBoolean("drafts", drafts != null); + } catch (Throwable ex) { + Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); + result.putBoolean("drafts", false); + } return result; } }