From 63e2908d3623c1adc24f247eda4628df4f36cb39 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sat, 5 Sep 2020 04:48:45 +0530 Subject: Migrations: use runCatching to replace exception handling Signed-off-by: Harsh Shandilya --- app/src/main/java/com/zeapo/pwdstore/Migrations.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/com/zeapo/pwdstore/Migrations.kt b/app/src/main/java/com/zeapo/pwdstore/Migrations.kt index 0e912141..18aed20e 100644 --- a/app/src/main/java/com/zeapo/pwdstore/Migrations.kt +++ b/app/src/main/java/com/zeapo/pwdstore/Migrations.kt @@ -11,6 +11,8 @@ import android.content.SharedPreferences import androidx.core.content.edit import com.github.ajalt.timberkt.e import com.github.ajalt.timberkt.i +import com.github.michaelbull.result.get +import com.github.michaelbull.result.runCatching import com.zeapo.pwdstore.git.config.GitSettings import com.zeapo.pwdstore.git.config.Protocol import com.zeapo.pwdstore.git.sshj.SshKey @@ -65,14 +67,12 @@ private fun migrateToGitUrlBasedConfig(sharedPrefs: SharedPreferences) { urlWithFreeEntryScheme.startsWith("http://") -> urlWithFreeEntryScheme.replaceFirst("http", "https") else -> "https://$urlWithFreeEntryScheme" } - try { + runCatching { if (URI(url).rawAuthority != null) url else null - } catch (_: Exception) { - null - } + }.get() } } -- cgit v1.2.3