aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2020-09-05 20:34:04 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2020-09-05 22:49:36 +0530
commit58f28727c168966f2b3386097b91abbbeeac31d7 (patch)
tree458c450a2ab68c9468d49014624729aaf9fe2e4f /app/src/main
parent4082be7721eb490f3d96825697a50ba99c80d136 (diff)
GitLogModel: 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/git/log/GitLogModel.kt8
1 files changed, 5 insertions, 3 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/log/GitLogModel.kt b/app/src/main/java/com/zeapo/pwdstore/git/log/GitLogModel.kt
index 22c1ec78..ccd2f88a 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/log/GitLogModel.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/git/log/GitLogModel.kt
@@ -6,6 +6,8 @@
package com.zeapo.pwdstore.git.log
import com.github.ajalt.timberkt.e
+import com.github.michaelbull.result.getOrElse
+import com.github.michaelbull.result.runCatching
import com.zeapo.pwdstore.utils.PasswordRepository
import com.zeapo.pwdstore.utils.hash
import com.zeapo.pwdstore.utils.time
@@ -18,10 +20,10 @@ private fun commits(): Iterable<RevCommit> {
e { "Could not access git repository" }
return listOf()
}
- return try {
+ return runCatching {
Git(repo).log().call()
- } catch (exc: Exception) {
- e(exc) { "Failed to obtain git commits" }
+ }.getOrElse { e ->
+ e(e) { "Failed to obtain git commits" }
listOf()
}
}