Skip to content

Commit

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

import android.content.res.Resources
import androidx.annotation.StringRes
import au.com.shiftyjelly.pocketcasts.utils.SentryHelper
import java.util.Locale
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 +44,13 @@ 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) {
val message = "Failed to convert time $amount to funny text ${ex.message} in language ${Locale.getDefault().language}."
SentryHelper.recordException(message, ex)
""
}
}

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

0 comments on commit d32332e

Please sign in to comment.