diff --git a/feature/converter/src/main/java/com/sadellie/unitto/feature/converter/MainViewModel.kt b/feature/converter/src/main/java/com/sadellie/unitto/feature/converter/MainViewModel.kt index ceaed4dd..649a387f 100644 --- a/feature/converter/src/main/java/com/sadellie/unitto/feature/converter/MainViewModel.kt +++ b/feature/converter/src/main/java/com/sadellie/unitto/feature/converter/MainViewModel.kt @@ -436,11 +436,16 @@ class MainViewModel @Inject constructor( Expressions().eval(cleanInput) } catch (e: Exception) { when (e) { + // Invalid expression, don't do anything is ArrayIndexOutOfBoundsException, is IndexOutOfBoundsException, - is NumberFormatException, - is ExpressionException, - is ArithmeticException -> return + is ExpressionException -> return + // Divide by zero or SQRT of negative + is NumberFormatException, is ArithmeticException -> { + _calculated.update { null } + _result.update { "" } + return + } else -> throw e } }