Better error message when you cannot determine a ROD type because the file doesn't exist or cannot be read

This commit is contained in:
Mark DePristo 2011-08-23 10:56:37 -04:00
parent a9ba945595
commit 6d6feb5540
1 changed files with 8 additions and 4 deletions

View File

@ -379,12 +379,16 @@ class RodBindingArgumentTypeDescriptor extends ArgumentTypeDescriptor {
} }
if ( tribbleType == null ) if ( tribbleType == null )
if ( ! file.canRead() | !! file.isFile() ) {
throw new UserException.BadArgumentValue(name, "Couldn't read file to determine type: " + file);
} else {
throw new UserException.CommandLineException( throw new UserException.CommandLineException(
String.format("No tribble type was provided on the command line and the type of the file could not be determined dynamically. " + String.format("No tribble type was provided on the command line and the type of the file could not be determined dynamically. " +
"Please add an explicit type tag :NAME listing the correct type from among the supported types:%n%s", "Please add an explicit type tag :NAME listing the correct type from among the supported types:%n%s",
manager.userFriendlyListOfAvailableFeatures(parameterType))); manager.userFriendlyListOfAvailableFeatures(parameterType)));
} }
} }
}
Constructor ctor = (makeRawTypeIfNecessary(type)).getConstructor(Class.class, String.class, String.class, String.class, Tags.class); Constructor ctor = (makeRawTypeIfNecessary(type)).getConstructor(Class.class, String.class, String.class, String.class, Tags.class);
RodBinding result = (RodBinding)ctor.newInstance(parameterType, name, value, tribbleType, tags); RodBinding result = (RodBinding)ctor.newInstance(parameterType, name, value, tribbleType, tags);