diff --git a/app/src/main/java/app/grapheneos/pdfviewer/KtUtils.kt b/app/src/main/java/app/grapheneos/pdfviewer/KtUtils.kt index 3f67aa6..175ede3 100644 --- a/app/src/main/java/app/grapheneos/pdfviewer/KtUtils.kt +++ b/app/src/main/java/app/grapheneos/pdfviewer/KtUtils.kt @@ -7,7 +7,12 @@ import java.io.IOException import java.io.InputStream import java.io.OutputStream -@Throws(FileNotFoundException::class, IOException::class) +@Throws( + FileNotFoundException::class, + IOException::class, + IllegalArgumentException::class, + OutOfMemoryError::class +) fun saveAs(context: Context, existingUri: Uri, saveAs: Uri) { context.asInputStream(existingUri)?.use { inputStream -> diff --git a/app/src/main/java/app/grapheneos/pdfviewer/PdfViewer.java b/app/src/main/java/app/grapheneos/pdfviewer/PdfViewer.java index ca2ad96..2049a1b 100644 --- a/app/src/main/java/app/grapheneos/pdfviewer/PdfViewer.java +++ b/app/src/main/java/app/grapheneos/pdfviewer/PdfViewer.java @@ -709,8 +709,7 @@ public class PdfViewer extends AppCompatActivity implements LoaderManager.Loader private void saveDocumentAs(Uri uri) { try { KtUtilsKt.saveAs(this, mUri, uri); - } catch (IOException e) { - e.printStackTrace(); + } catch (IOException | OutOfMemoryError | IllegalArgumentException e) { snackbar.setText(R.string.error_while_saving).show(); } }