Skip to content

Commit

Permalink
Handle as_int error with a fallback gracefully
Browse files Browse the repository at this point in the history
as_int was previously not fallback-compatible
as_double and as_money too
  • Loading branch information
mcmonkey4eva committed Sep 27, 2014
1 parent 830d84e commit 3b1fbb1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/net/aufdemrand/denizen/objects/Element.java
Expand Up @@ -371,8 +371,8 @@ public String getAttribute(Attribute attribute) {
try { return new Element(Double.valueOf(element))
.getAttribute(attribute.fulfill(1)); }
catch (NumberFormatException e) {
dB.echoError("'" + element + "' is not a valid Double.");
return new Element("null").getAttribute(attribute.fulfill(1));
if (!attribute.hasAlternative())
dB.echoError("'" + element + "' is not a valid Double.");
}

// <--[tag]
Expand All @@ -391,8 +391,8 @@ public String getAttribute(Attribute attribute) {
return new Element(Math.round(Double.valueOf(element)))
.getAttribute(attribute.fulfill(1)); }
catch (NumberFormatException e) {
dB.echoError("'" + element + "' is not a valid Integer.");
return new Element("null").getAttribute(attribute.fulfill(1));
if (!attribute.hasAlternative())
dB.echoError("'" + element + "' is not a valid Integer.");
}

// <--[tag]
Expand All @@ -409,8 +409,8 @@ public String getAttribute(Attribute attribute) {
return new Element(d.format(Double.valueOf(element)))
.getAttribute(attribute.fulfill(1)); }
catch (NumberFormatException e) {
dB.echoError("'" + element + "' is not a valid number.");
return new Element("null").getAttribute(attribute.fulfill(1));
if (!attribute.hasAlternative())
dB.echoError("'" + element + "' is not a valid number.");
}
}

Expand Down

0 comments on commit 3b1fbb1

Please sign in to comment.