Skip to content

Commit

Permalink
show an error for invalid number input to tags
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Nov 12, 2019
1 parent 301588a commit b2bb3c6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/com/denizenscript/denizencore/tags/Attribute.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,10 @@ public int getIntContext(int attribute) {
return Integer.valueOf(getContext(attribute));
}
}
catch (Exception e) {
catch (Exception ex) {
if (!hasAlternative()) {
Debug.echoError("Tag <" + toString() + "> has invalid input - expected a number, got '" + getContext(attribute) + "'...: " + ex.getMessage());
}
}

return 0;
Expand All @@ -294,7 +297,10 @@ public double getDoubleContext(int attribute) {
return Double.valueOf(getContext(attribute));
}
}
catch (Exception e) {
catch (NumberFormatException ex) {
if (!hasAlternative()) {
Debug.echoError("Tag <" + toString() + "> has invalid input - expected a decimal number, got '" + getContext(attribute) + "'...: " + ex.getMessage());
}
}
return 0;
}
Expand Down

0 comments on commit b2bb3c6

Please sign in to comment.