Skip to content

Commit 41897c3

Browse files
t3dotggclaude
andcommitted
refactor(mobile): drop the Kotlin catch suppression
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent b3583ca commit 41897c3

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

‎apps/mobile/modules/t3-native-controls/android/src/main/java/expo/modules/t3nativecontrols/T3NativeControlsModule.kt‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ class T3NativeControlsModule : Module() {
103103

104104
// Android 10+ lets apps add their own media without a storage permission.
105105
@RequiresApi(Build.VERSION_CODES.Q)
106-
@Suppress("TooGenericExceptionCaught") // Remove the pending entry before rethrowing.
107106
private fun saveImageToPictures(context: Context, source: Uri, mimeType: String, name: String) {
108107
val resolver = context.contentResolver
109108
val values = ContentValues().apply {
@@ -116,7 +115,7 @@ private fun saveImageToPictures(context: Context, source: Uri, mimeType: String,
116115
MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY),
117116
values
118117
) ?: error("Could not create the image in Pictures.")
119-
try {
118+
runCatching {
120119
val input = resolver.openInputStream(source) ?: error("The image is no longer available.")
121120
input.use { from ->
122121
val output = resolver.openOutputStream(target) ?: error("Could not write the image.")
@@ -128,8 +127,5 @@ private fun saveImageToPictures(context: Context, source: Uri, mimeType: String,
128127
null,
129128
null
130129
)
131-
} catch (error: Exception) {
132-
resolver.delete(target, null, null)
133-
throw error
134-
}
130+
}.onFailure { resolver.delete(target, null, null) }.getOrThrow()
135131
}

0 commit comments

Comments
 (0)