Migrations: use runCatching to replace exception handling

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
Harsh Shandilya 2020-09-05 04:48:45 +05:30
parent c3e6006895
commit 63e2908d36
No known key found for this signature in database
GPG Key ID: 366D7BBAD1031E80

View File

@ -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()
}
}