From f91137b770d04990f6a75d0bbf261fd455776be2 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 10 Feb 2023 18:38:08 +0100 Subject: [PATCH] catch and show an exception --- .../simplemobiletools/calculator/helpers/CalculatorImpl.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/CalculatorImpl.kt b/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/CalculatorImpl.kt index 5ff4804e..8f72e4cb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/CalculatorImpl.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/CalculatorImpl.kt @@ -223,7 +223,12 @@ class CalculatorImpl( return } - baseValue = parts.first().toDouble() + try { + baseValue = parts.first().toDouble() + } catch (e: NumberFormatException) { + context.showErrorToast(e) + } + if (inputDisplayedFormula.startsWith("-")) { baseValue *= -1 }