Repository: expo/expo
File: packages/expo-media-library/android/src/main/java/expo/modules/medialibrary/next/objects/asset/delegates/AssetModernDelegate.kt (Kotlin)

Code before:
            "int" -> exifBundle.putInt(name, exifInterface.getAttributeInt(name, 0))
            "double" -> exifBundle.putDouble(name, exifInterface.getAttributeDouble(name, 0.0))
          }
        }
      }
    }
    return@withContext exifBundle
  }

  override suspend fun delete() = withContext(Dispatchers.IO) {
    assetDeleter.delete(contentUri)
  }

  override suspend fun move(relativePath: RelativePath) {
    mediaStorePermissionsDelegate.requestMediaLibraryWritePermission(listOf(contentUri))

    try {
      contentResolver.updateRelativePath(contentUri, relativePath)
    } catch (e: Exception) {
      if (e.message?.contains("Failed to build unique file", ignoreCase = true) == true) {
        val uniqueName = buildUniqueDisplayName(getUri())
        contentResolver.updateRelativePathAndName(contentUri, relativePath, uniqueName)
      } else {
        throw e
      }
    }
  }

  override suspend fun copy(relativePath: RelativePath): Asset =
    copyInternal(relativePath, forceUniqueName = false)

  private suspend fun copyInternal(relativePath: RelativePath, forceUniqueName: Boolean): Asset = withContext(Dispatchers.IO) {
    val displayName = if (forceUniqueName) {
      buildUniqueDisplayName(getUri())
    } else {
      getUri().toString()
    }
    var newAssetUri: Uri? = null

    try {
      newAssetUri = contentResolver.insertPendingAsset(displayName, getMimeType(), relativePath)
      ensureActive()
      contentResolver.copyUriContent(contentUri, newAssetUri)
      ensureActive()
      contentResolver.publishPendingAsset(newAssetUri)

      val newAssetDelegate = AssetModernDelegate(
        newAssetUri,
        assetDeleter,
        mediaStorePermissionsDelegate,
        contextRef.getOrThrow()

Review comment (bug):
```suggestion
    } catch (e: IllegalStateException) {
      if (e.message?.contains("Failed to build unique file", ignoreCase = true) == true) {
        val uniqueName = buildUniqueDisplayName(getUri())
        contentResolver.updateRelativePathAndName(contentUri, relativePath, uniqueName)
      } else {
        throw e
      }
    }
```
We don't need to catch all exceptions

Code after:
            "int" -> exifBundle.putInt(name, exifInterface.getAttributeInt(name, 0))
            "double" -> exifBundle.putDouble(name, exifInterface.getAttributeDouble(name, 0.0))
          }
        }
      }
    }
    return@withContext exifBundle
  }

  override suspend fun delete() = withContext(Dispatchers.IO) {
    assetDeleter.delete(contentUri)
  }

  override suspend fun move(relativePath: RelativePath) {
    mediaStorePermissionsDelegate.requestMediaLibraryWritePermission(listOf(contentUri))

    try {
      contentResolver.updateRelativePath(contentUri, relativePath)
    } catch (e: IllegalStateException) {
      if (e.message?.contains("Failed to build unique file", ignoreCase = true) == true) {
        val uniqueName = buildUniqueDisplayName(getUri())
        contentResolver.updateRelativePathAndName(contentUri, relativePath, uniqueName)
      } else {
        throw e
      }
    }
  }

  override suspend fun copy(relativePath: RelativePath): Asset =
    copyInternal(relativePath, forceUniqueName = false)

  private suspend fun copyInternal(relativePath: RelativePath, forceUniqueName: Boolean): Asset = withContext(Dispatchers.IO) {
    val displayName = if (forceUniqueName) {
      buildUniqueDisplayName(getUri())
    } else {
      getUri().toString()
    }
    val newAssetUri = contentResolver.insertPendingAsset(
      displayName,
      getMimeType(),
      relativePath
    )
    return@withContext try {
      ensureActive()
      contentResolver.copyUriContent(contentUri, newAssetUri)
      ensureActive()
      contentResolver.publishPendingAsset(newAssetUri)
      val newAssetDelegate = AssetModernDelegate(
        newAssetUri,
        assetDeleter,
        mediaStorePermissionsDelegate,