Skip to content

Commit

Permalink
Expression error messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
pnemonic78 committed Jan 6, 2025
1 parent 1425ef6 commit 6bd4870
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,13 @@ public String evaluate() {
money.getNumerator();
} catch (ArithmeticException e) {
setError(getContext().getString(R.string.label_error_invalid_expression));
Timber.w(e, "Invalid expression: %s", amountString);
Timber.w(e, "Invalid amount: %s", amountString);
return "";
}
setValue(amount);
} else {
setError(getContext().getString(R.string.label_error_invalid_expression));
Timber.w("Invalid expression: %s", amountString);
Timber.w("Invalid amount: %s", amountString);
}
return getText().toString();
}
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/org/gnucash/android/util/AmountParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public static BigDecimal evaluate(@Nullable String expressionString) {
if (TextUtils.isEmpty(expressionString)) {
return null;
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
return evaluate16(expressionString);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
return evaluate26(expressionString);
}
return evaluate26(expressionString);
return evaluate16(expressionString);
}

@Nullable
Expand All @@ -66,7 +66,7 @@ private static BigDecimal evaluate16(@NonNull String expressionString) {
return new BigDecimal(expression.evaluate());
}
} catch (Exception e) {
Timber.w(e, "Invalid amount: %s", expressionString);
Timber.w(e, "Invalid expression: %s", expressionString);
}
return null;
}
Expand All @@ -81,7 +81,7 @@ private static BigDecimal evaluate26(@NonNull String expressionString) {
return value.getNumberValue();
}
} catch (Exception e) {
Timber.w(e, "Invalid amount: %s", expressionString);
Timber.w(e, "Invalid expression: %s", expressionString);
}
return null;
}
Expand Down

0 comments on commit 6bd4870

Please sign in to comment.