Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Secure no crashes in SyncExchangeRatesAct.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
ILIYANGERMANOV committed Dec 27, 2022
1 parent fe41a7d commit e26e30f
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ class SyncExchangeRatesAct @Inject constructor(
}

override suspend fun Input.willDo() = io {
sync(baseCurrency)
try {
sync(baseCurrency)
} catch (e: Exception) {
e.printStackTrace()
}
}

private suspend fun sync(baseCurrency: String) {
Expand All @@ -49,7 +53,8 @@ class SyncExchangeRatesAct @Inject constructor(
"usd": 1.062366,
}
*/
val eurBaseCurr = eurRates[baseCurrencyLower] ?: return
val eurBaseCurr = eurRates[baseCurrencyLower]
?.takeIf { it > 0 } ?: return

val rateEntities = eurRates.mapNotNull { (target, rate) ->
try {
Expand Down

0 comments on commit e26e30f

Please sign in to comment.