Extensions: use runCatching to replace exception handling
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
730da7ef0f
commit
2041ec3f19
1 changed files with 4 additions and 2 deletions
|
@ -27,6 +27,8 @@ import androidx.security.crypto.MasterKey
|
||||||
import com.github.ajalt.timberkt.d
|
import com.github.ajalt.timberkt.d
|
||||||
import com.github.michaelbull.result.Ok
|
import com.github.michaelbull.result.Ok
|
||||||
import com.github.michaelbull.result.Result
|
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.google.android.material.snackbar.Snackbar
|
||||||
import com.zeapo.pwdstore.R
|
import com.zeapo.pwdstore.R
|
||||||
import com.zeapo.pwdstore.git.operation.GitOperation
|
import com.zeapo.pwdstore.git.operation.GitOperation
|
||||||
|
@ -77,9 +79,9 @@ fun File.contains(other: File): Boolean {
|
||||||
return false
|
return false
|
||||||
if (!other.exists())
|
if (!other.exists())
|
||||||
return false
|
return false
|
||||||
val relativePath = try {
|
val relativePath = runCatching {
|
||||||
other.relativeTo(this)
|
other.relativeTo(this)
|
||||||
} catch (e: Exception) {
|
}.getOrElse {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// Direct containment is equivalent to the relative path being equal to the filename.
|
// Direct containment is equivalent to the relative path being equal to the filename.
|
||||||
|
|
Loading…
Reference in a new issue