Skip to content

Commit 89dd6e7

Browse files
committed
refactor: replace try catch with runCatching
1 parent 2f1b45d commit 89dd6e7

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

app/src/main/java/to/bitkit/utils/timedsheets/sheets/AppUpdateTimedSheet.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,19 @@ class AppUpdateTimedSheet @Inject constructor(
1818
override val priority = 5
1919

2020
override suspend fun shouldShow(): Boolean = withContext(bgDispatcher) {
21-
try {
21+
return@withContext runCatching {
2222
val androidReleaseInfo = appUpdaterService.getReleaseInfo().platforms.android
2323
val currentBuildNumber = BuildConfig.VERSION_CODE
2424

2525
if (androidReleaseInfo.buildNumber <= currentBuildNumber) return@withContext false
2626

2727
if (androidReleaseInfo.isCritical) {
28-
return@withContext false
28+
return@runCatching false
2929
}
30-
31-
return@withContext true
32-
} catch (e: Exception) {
30+
return@runCatching true
31+
}.onFailure { e ->
3332
Logger.warn("Failure fetching new releases", e = e, context = TAG)
34-
return@withContext false
35-
}
33+
}.getOrDefault(false)
3634
}
3735

3836
override suspend fun onShown() {

0 commit comments

Comments
 (0)