From 8103d1503019ea11ae665bcd6c9651e4c89da156 Mon Sep 17 00:00:00 2001 From: Gibran Chevalley Date: Wed, 23 Oct 2024 13:14:31 +0200 Subject: [PATCH] Add stream errors breadbrumbs --- .../ui/screen/newtransfer/UploadLocalStorage.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/UploadLocalStorage.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/UploadLocalStorage.kt index 635922b4d..737c2b3cf 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/UploadLocalStorage.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/UploadLocalStorage.kt @@ -24,6 +24,7 @@ import com.infomaniak.swisstransfer.ui.components.FileUi import com.infomaniak.swisstransfer.ui.screen.newtransfer.NewTransferViewModel.Companion.LOCAL_COPY_FOLDER import dagger.hilt.android.qualifiers.ApplicationContext import io.sentry.Sentry +import io.sentry.SentryLevel import java.io.File import javax.inject.Inject import javax.inject.Singleton @@ -50,7 +51,13 @@ class UploadLocalStorage @Inject constructor(@ApplicationContext private val app runCatching { createNewFile() }.onFailure { return null } runCatching { - val inputStream = appContext.contentResolver.openInputStream(uri) ?: return null + val inputStream = appContext.contentResolver.openInputStream(uri) ?: run { + Sentry.withScope { scope -> + scope.level = SentryLevel.ERROR + Sentry.addBreadcrumb("During local copy of the file openInputStream returned null") + } + return null + } inputStream.use { inputStream -> outputStream().use { outputStream -> @@ -58,6 +65,10 @@ class UploadLocalStorage @Inject constructor(@ApplicationContext private val app } } }.onFailure { + Sentry.withScope { scope -> + scope.level = SentryLevel.ERROR + Sentry.addBreadcrumb("Caught an exception while copying file to local storage: $it") + } return null } }