Browse Source

Make sure the error messages are all in resources bundle and are passed appropriate parameters.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270401 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 23 years ago
parent
commit
aaa47427c1
2 changed files with 6 additions and 2 deletions
  1. +5
    -0
      proposal/myrmidon/src/java/org/apache/antlib/core/Resources.properties
  2. +1
    -2
      proposal/myrmidon/src/java/org/apache/antlib/core/StringToEnumConverter.java

+ 5
- 0
proposal/myrmidon/src/java/org/apache/antlib/core/Resources.properties View File

@@ -13,3 +13,8 @@ convert.bad-integer.error=Error converting object ({0}) to Integer.
convert.bad-long.error=Error converting object ({0}) to Long.
convert.bad-short.error=Error converting object ({0}) to Short.
convert.bad-url.error=Error converting object ({0}) to URL.

getByName.error=Failed to retrieve enum by calling getByName on "{0}". (Reason: {1}).
enum.missing.getByName.error=Enum class "{0}" is missing a public static method named "getByName" that accepts a single string parameter.
enum.missing.getNames.error=Enum class "{0}" is missing a public static method named "getNames" that returns a String array of all enum names.
invalid.enum.error=Invalid value "{0}" for enum, expected one of {1}.

+ 1
- 2
proposal/myrmidon/src/java/org/apache/antlib/core/StringToEnumConverter.java View File

@@ -33,12 +33,11 @@ public class StringToEnumConverter
throws ConverterException
{
final Object object = getEnum( destination, original );

if( null == object )
{
final String[] names = getValidNames( destination );
final String message =
REZ.getString( "invalid.enum.error", object, Arrays.asList( names ) );
REZ.getString( "invalid.enum.error", original, Arrays.asList( names ) );
throw new ConverterException( message );
}
else


Loading…
Cancel
Save