Browse Source

special handling of IllegalArgumentExceptions in attribute setters for better error messages. PR 47129

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@772606 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 16 years ago
parent
commit
7984fd2400
1 changed files with 15 additions and 0 deletions
  1. +15
    -0
      src/main/org/apache/tools/ant/IntrospectionHelper.java

+ 15
- 0
src/main/org/apache/tools/ant/IntrospectionHelper.java View File

@@ -1139,6 +1139,10 @@ public final class IntrospectionHelper {
try {
m.invoke(parent, new Object[] {
new Long(StringUtils.parseHumanSizes(value)) });
} catch (NumberFormatException e) {
throw new BuildException("Can't assign non-numeric"
+ " value '" + value + "' to"
+ " attribute " + attrName);
} catch (InvocationTargetException e) {
throw e;
} catch (IllegalAccessException e) {
@@ -1184,6 +1188,17 @@ public final class IntrospectionHelper {
p.setProjectReference(attribute);
}
m.invoke(parent, new Object[] {attribute});
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
if (cause instanceof IllegalArgumentException) {
throw new BuildException("Can't assign value '" + value
+ "' to attribute " + attrName
+ ", reason: "
+ cause.getClass()
+ " with message '"
+ cause.getMessage() + "'");
}
throw e;
} catch (InstantiationException ie) {
throw new BuildException(ie);
}


Loading…
Cancel
Save