Fix for RefSeqCodec bug and better error messages

-- RefSeqCodec bug: getFeatureClass() returned RefSeqCodec.class, not RefSeqFeature.class.  Really should change this in Tribble to require Class<T extends Feature> to get compile time type checking
-- Better error messages that actually list the available tribble types, when there's a type error
This commit is contained in:
Mark DePristo 2011-08-17 16:22:07 -04:00
parent 53006da9a5
commit d59e6ed274
3 changed files with 119 additions and 119 deletions

View File

@ -373,16 +373,16 @@ class RodBindingArgumentTypeDescriptor extends ArgumentTypeDescriptor {
if ( featureDescriptor != null ) { if ( featureDescriptor != null ) {
tribbleType = featureDescriptor.getName(); tribbleType = featureDescriptor.getName();
logger.warn("Dynamically determined type of " + file + " to be " + tribbleType); logger.warn("Dynamically determined type of " + file + " to be " + tribbleType);
} else {
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. " +
"Please add an explicit type tag :TYPE listing the correct type from among the supported types: %s",
manager.userFriendlyListOfAvailableFeatures()));
} }
} }
} }
} }
if ( tribbleType == null ) // error handling
throw new UserException.CommandLineException(
String.format("Could not parse argument %s with value %s",
defaultDefinition.fullName, value));
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);
Class parameterType = getParameterizedTypeClass(type); Class parameterType = getParameterizedTypeClass(type);
RodBinding result = (RodBinding)ctor.newInstance(parameterType, name, value, tribbleType, tags); RodBinding result = (RodBinding)ctor.newInstance(parameterType, name, value, tribbleType, tags);
@ -395,8 +395,8 @@ class RodBindingArgumentTypeDescriptor extends ArgumentTypeDescriptor {
value, source.field.getName())); value, source.field.getName()));
} catch (Exception e) { } catch (Exception e) {
throw new UserException.CommandLineException( throw new UserException.CommandLineException(
String.format("Failed to parse value %s for argument %s.", String.format("Failed to parse value %s for argument %s. Message: %s",
value, source.field.getName())); value, source.field.getName(), e.getMessage()));
} }
} }

View File

@ -105,6 +105,6 @@ public class RefSeqCodec implements ReferenceDependentFeatureCodec<RefSeqFeature
@Override @Override
public Class getFeatureType() { public Class getFeatureType() {
return RefSeqCodec.class; return RefSeqFeature.class;
} }
} }

View File

@ -160,8 +160,8 @@ public class ListFileUtils {
rodBinding.getName(), rodBinding.getTribbleType(), builderForValidation.userFriendlyListOfAvailableFeatures())); rodBinding.getName(), rodBinding.getTribbleType(), builderForValidation.userFriendlyListOfAvailableFeatures()));
if ( ! rodBinding.getType().isAssignableFrom(descriptor.getFeatureClass()) ) if ( ! rodBinding.getType().isAssignableFrom(descriptor.getFeatureClass()) )
throw new UserException.BadArgumentValue(rodBinding.getName(), throw new UserException.BadArgumentValue(rodBinding.getName(),
String.format("Field %s expected type %s, but the type of the input file provided on the command line was %s. Please make sure that you have provided the correct file type and/or that you are not binding your rod to a name matching one of the available types.", String.format("Field %s expected type %s, but the type of the input file provided on the command line was %s producing %s. Please make sure that you have provided the correct file type and/or that you are not binding your rod to a name matching one of the available types.",
rodBinding.getName(), rodBinding.getType(), descriptor.getName())); rodBinding.getName(), rodBinding.getType(), descriptor.getName(), descriptor.getFeatureClass()));
rodBindings.add(triplet); rodBindings.add(triplet);