diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt index 390516e0a..b481eff35 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NumberUtil.kt @@ -189,10 +189,15 @@ object NumberUtil { // TODO create new function formatLong, and eventually deprecate this function. @Deprecated("renamed", ReplaceWith("this.formatLong()")) - fun String.formatNumber(): Long = formatLong() ?: error("formatNumber has a NumberFormatException with '$this'") + fun String.formatNumber(): Long = formatLong() ?: throw NumberFormatException("formatNumber has a NumberFormatException with '$this'") fun String.formatLong(): Long? = formatDouble()?.toLong() + fun String.formatLongOrUserError(): Long? = formatDouble()?.toLong() ?: run { + ChatUtils.userError("Not a valid number: '$this'") + return@run null + } + fun String.formatDouble(): Double? { var text = lowercase().replace(",", "") |
