aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2020-09-05 05:48:27 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2020-09-05 22:49:03 +0530
commit2041ec3f19318777c456ae6e2075f0aff74c45a7 (patch)
tree4e93235611f661bfee9bcd9351f5cf66c400b901 /app
parent730da7ef0faf55f7bb90eccc41e7b57997ba839d (diff)
Extensions: 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/utils/Extensions.kt6
1 files changed, 4 insertions, 2 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/utils/Extensions.kt b/app/src/main/java/com/zeapo/pwdstore/utils/Extensions.kt
index ab78e98f..d54e26cd 100644
--- a/app/src/main/java/com/zeapo/pwdstore/utils/Extensions.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/utils/Extensions.kt
@@ -27,6 +27,8 @@ import androidx.security.crypto.MasterKey
import com.github.ajalt.timberkt.d
import com.github.michaelbull.result.Ok
import com.github.michaelbull.result.Result
+import com.github.michaelbull.result.getOrElse
+import com.github.michaelbull.result.runCatching
import com.google.android.material.snackbar.Snackbar
import com.zeapo.pwdstore.R
import com.zeapo.pwdstore.git.operation.GitOperation
@@ -77,9 +79,9 @@ fun File.contains(other: File): Boolean {
return false
if (!other.exists())
return false
- val relativePath = try {
+ val relativePath = runCatching {
other.relativeTo(this)
- } catch (e: Exception) {
+ }.getOrElse {
return false
}
// Direct containment is equivalent to the relative path being equal to the filename.