Skip to content

Commit f0e9780

Browse files
committed
refactor: replace tryCatch with runCatching
1 parent 45c5b08 commit f0e9780

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

app/src/main/java/to/bitkit/services/CoreService.kt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,11 @@ class ActivityService(
262262
payments.chunked(CHUNCK_SIZE).forEach { chunk ->
263263
val results = chunk.map { payment ->
264264
async {
265-
try {
265+
runCatching {
266266
processSinglePayment(payment, forceUpdate)
267-
Result.success(payment.id)
268-
} catch (e: Throwable) {
267+
payment.id
268+
}.onFailure { e ->
269269
Logger.error("Error syncing payment ${payment.id}:", e, context = "CoreService")
270-
Result.failure<String>(e)
271270
}
272271
}
273272
}.awaitAll()
@@ -281,11 +280,6 @@ class ActivityService(
281280
"Synced ${successful.size} payments successfully, ${failed.size} failed",
282281
context = "CoreService"
283282
)
284-
285-
// Throw if too many failed
286-
if (failed.size > payments.size * 0.5) {
287-
throw Exception("Too many payment sync failures: ${failed.size}/${payments.size}")
288-
}
289283
}
290284
}
291285
}

0 commit comments

Comments
 (0)