diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2020-09-05 20:31:28 +0530 |
---|---|---|
committer | Harsh Shandilya <me@msfjarvis.dev> | 2020-09-05 22:49:35 +0530 |
commit | 82c83a5bedcb71a997e099d782e36e328162d91e (patch) | |
tree | c9fa4ee66cfbfb7e8da0f541d0e27d5f552e6eb1 /app | |
parent | 83654896b6acc66793f4b279e0a41a0e15b988c4 (diff) |
GitSettings: use runCatching to replace exception handling
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/git/config/GitSettings.kt | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/config/GitSettings.kt b/app/src/main/java/com/zeapo/pwdstore/git/config/GitSettings.kt index b0d931e0..1169345b 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/config/GitSettings.kt +++ b/app/src/main/java/com/zeapo/pwdstore/git/config/GitSettings.kt @@ -5,6 +5,8 @@ package com.zeapo.pwdstore.git.config 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.utils.PasswordRepository import com.zeapo.pwdstore.utils.PreferenceKeys @@ -105,9 +107,9 @@ object GitSettings { } fun updateConnectionSettingsIfValid(newAuthMode: AuthMode, newUrl: String, newBranch: String): UpdateConnectionSettingsResult { - val parsedUrl = try { + val parsedUrl = runCatching { URIish(newUrl) - } catch (_: Exception) { + }.getOrElse { return UpdateConnectionSettingsResult.FailedToParseUrl } val newProtocol = when (parsedUrl.scheme) { |