Skip to content

Commit

Permalink
Capture unknown format conversion exception
Browse files Browse the repository at this point in the history
  • Loading branch information
ashiagr committed Nov 30, 2022
1 parent a3211c4 commit e4fb26e
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package au.com.shiftyjelly.pocketcasts.settings.util

import android.content.res.Resources
import androidx.annotation.StringRes
import timber.log.Timber
import java.util.Random
import java.util.UnknownFormatConversionException
import au.com.shiftyjelly.pocketcasts.localization.R as LR

class FunnyTimeConverter {
Expand Down Expand Up @@ -41,7 +43,12 @@ class FunnyTimeConverter {
val mins = (timeSecs / 60).toDouble()
val amount = mins * timesPerMinute

return resources.getString(formatStringId, amount)
return try {
resources.getString(formatStringId, amount)
} catch (ex: UnknownFormatConversionException) {
Timber.e(ex.message)
""
}
}

fun suitableFor(timeSecs: Long): Boolean {
Expand Down

0 comments on commit e4fb26e

Please sign in to comment.