mirror of
https://github.com/android-password-store/Android-Password-Store.git
synced 2025-09-07 16:09:38 +02:00
GitSettings: use runCatching to replace exception handling
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
83654896b6
commit
82c83a5bed
|
@ -5,6 +5,8 @@
|
||||||
package com.zeapo.pwdstore.git.config
|
package com.zeapo.pwdstore.git.config
|
||||||
|
|
||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
|
import com.github.michaelbull.result.getOrElse
|
||||||
|
import com.github.michaelbull.result.runCatching
|
||||||
import com.zeapo.pwdstore.Application
|
import com.zeapo.pwdstore.Application
|
||||||
import com.zeapo.pwdstore.utils.PasswordRepository
|
import com.zeapo.pwdstore.utils.PasswordRepository
|
||||||
import com.zeapo.pwdstore.utils.PreferenceKeys
|
import com.zeapo.pwdstore.utils.PreferenceKeys
|
||||||
|
@ -105,9 +107,9 @@ object GitSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateConnectionSettingsIfValid(newAuthMode: AuthMode, newUrl: String, newBranch: String): UpdateConnectionSettingsResult {
|
fun updateConnectionSettingsIfValid(newAuthMode: AuthMode, newUrl: String, newBranch: String): UpdateConnectionSettingsResult {
|
||||||
val parsedUrl = try {
|
val parsedUrl = runCatching {
|
||||||
URIish(newUrl)
|
URIish(newUrl)
|
||||||
} catch (_: Exception) {
|
}.getOrElse {
|
||||||
return UpdateConnectionSettingsResult.FailedToParseUrl
|
return UpdateConnectionSettingsResult.FailedToParseUrl
|
||||||
}
|
}
|
||||||
val newProtocol = when (parsedUrl.scheme) {
|
val newProtocol = when (parsedUrl.scheme) {
|
||||||
|
|
Loading…
Reference in a new issue