ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r772606 - /ant/core/trunk/src/main/org/apache/tools/ant/IntrospectionHelper.java
Date Thu, 07 May 2009 10:58:29 GMT
Author: bodewig
Date: Thu May  7 10:58:29 2009
New Revision: 772606

URL: http://svn.apache.org/viewvc?rev=772606&view=rev
Log:
special handling of IllegalArgumentExceptions in attribute setters for better error messages.
 PR 47129

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/IntrospectionHelper.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/IntrospectionHelper.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/IntrospectionHelper.java?rev=772606&r1=772605&r2=772606&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/IntrospectionHelper.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/IntrospectionHelper.java Thu May  7 10:58:29
2009
@@ -1139,6 +1139,10 @@
                     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 @@
                         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);
                 }



Mime
View raw message