GitLogModel: use runCatching to replace exception handling
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
4082be7721
commit
58f28727c1
1 changed files with 5 additions and 3 deletions
|
@ -6,6 +6,8 @@
|
||||||
package com.zeapo.pwdstore.git.log
|
package com.zeapo.pwdstore.git.log
|
||||||
|
|
||||||
import com.github.ajalt.timberkt.e
|
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.PasswordRepository
|
||||||
import com.zeapo.pwdstore.utils.hash
|
import com.zeapo.pwdstore.utils.hash
|
||||||
import com.zeapo.pwdstore.utils.time
|
import com.zeapo.pwdstore.utils.time
|
||||||
|
@ -18,10 +20,10 @@ private fun commits(): Iterable<RevCommit> {
|
||||||
e { "Could not access git repository" }
|
e { "Could not access git repository" }
|
||||||
return listOf()
|
return listOf()
|
||||||
}
|
}
|
||||||
return try {
|
return runCatching {
|
||||||
Git(repo).log().call()
|
Git(repo).log().call()
|
||||||
} catch (exc: Exception) {
|
}.getOrElse { e ->
|
||||||
e(exc) { "Failed to obtain git commits" }
|
e(e) { "Failed to obtain git commits" }
|
||||||
listOf()
|
listOf()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue