From 5e067f553a3f023e2bcbf6ba56806d85ffeece1c Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 20 Feb 2020 11:45:34 +0100 Subject: [PATCH] Filter exceptions --- .../main/java/eu/faircode/email/FragmentBase.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentBase.java b/app/src/main/java/eu/faircode/email/FragmentBase.java index 69d3cc4ff5..2a190552ab 100644 --- a/app/src/main/java/eu/faircode/email/FragmentBase.java +++ b/app/src/main/java/eu/faircode/email/FragmentBase.java @@ -388,7 +388,9 @@ public class FragmentBase extends Fragment { return; } - if (ex instanceof IllegalArgumentException || ex instanceof FileNotFoundException) + if (ex instanceof IllegalArgumentException || + ex instanceof FileNotFoundException || + ex instanceof SecurityException) ToastEx.makeText(getContext(), ex.getMessage(), Toast.LENGTH_LONG).show(); else Log.unexpectedError(getParentFragmentManager(), ex); @@ -407,6 +409,11 @@ public class FragmentBase extends Fragment { long id = args.getLong("id"); Uri uri = args.getParcelable("uri"); + if (!"content".equals(uri.getScheme())) { + Log.w("Save attachment uri=" + uri); + throw new IllegalArgumentException(context.getString(R.string.title_no_stream)); + } + DB db = DB.getInstance(context); DocumentFile tree = DocumentFile.fromTreeUri(context, uri); List attachments = db.attachment().getAttachments(id); @@ -470,7 +477,9 @@ public class FragmentBase extends Fragment { return; } - if (ex instanceof FileNotFoundException) + if (ex instanceof IllegalArgumentException || + ex instanceof FileNotFoundException || + ex instanceof SecurityException) ToastEx.makeText(getContext(), ex.getMessage(), Toast.LENGTH_LONG).show(); else Log.unexpectedError(getParentFragmentManager(), ex);