aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2020-09-05 04:48:45 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2020-09-05 22:49:01 +0530
commit63e2908d3623c1adc24f247eda4628df4f36cb39 (patch)
treeae2fa79df040f48c24a2feb497bdae7302914e0a /app/src/main
parentc3e600689547ef850cb9dcaa3b01f97de543b9d5 (diff)
Migrations: use runCatching to replace exception handling
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/Migrations.kt8
1 files changed, 4 insertions, 4 deletions
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()
}
}