From 58f28727c168966f2b3386097b91abbbeeac31d7 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sat, 5 Sep 2020 20:34:04 +0530 Subject: GitLogModel: use runCatching to replace exception handling Signed-off-by: Harsh Shandilya --- app/src/main/java/com/zeapo/pwdstore/git/log/GitLogModel.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'app') 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 { 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() } } -- cgit v1.2.3