From 1e9fe2a334384d741a6966b04af1b4793f758d74 Mon Sep 17 00:00:00 2001 From: hanna Date: Wed, 20 Jan 2010 19:48:26 +0000 Subject: [PATCH] Clean up error output when enums have missing arguments. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2645 348d0f76-0448-11de-a6fe-93d51630548a --- .../sting/utils/cmdLine/ArgumentTypeDescriptor.java | 7 ++++++- .../sting/utils/cmdLine/CommandLineProgram.java | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/java/src/org/broadinstitute/sting/utils/cmdLine/ArgumentTypeDescriptor.java b/java/src/org/broadinstitute/sting/utils/cmdLine/ArgumentTypeDescriptor.java index 9c7db1d01..d2ee0e057 100644 --- a/java/src/org/broadinstitute/sting/utils/cmdLine/ArgumentTypeDescriptor.java +++ b/java/src/org/broadinstitute/sting/utils/cmdLine/ArgumentTypeDescriptor.java @@ -278,7 +278,12 @@ class SimpleArgumentTypeDescriptor extends ArgumentTypeDescriptor { catch (NoSuchFieldException e) { throw new StingException("parsing " + type.toString() + "doesn't contain the field " + val.toString()); } } // if their argument has no value (null), and there's a default, return that default for the enum value - if (defaultEnumeration != null && value == null) return defaultEnumeration; + if (defaultEnumeration != null && value == null) + return defaultEnumeration; + // if their argument has no value and there's no default, throw a missing argument value exception. + // TODO: Clean this up so that null values never make it to this point. To fix this, we'll have to clean up the implementation of -U. + if (value == null) + throw new MissingArgumentValueException(Collections.singleton(createDefaultArgumentDefinition(source))); throw new UnknownEnumeratedValueException(value, type.getName()); } else { Constructor ctor = type.getConstructor(String.class); diff --git a/java/src/org/broadinstitute/sting/utils/cmdLine/CommandLineProgram.java b/java/src/org/broadinstitute/sting/utils/cmdLine/CommandLineProgram.java index 20ff5b309..eb56e63aa 100644 --- a/java/src/org/broadinstitute/sting/utils/cmdLine/CommandLineProgram.java +++ b/java/src/org/broadinstitute/sting/utils/cmdLine/CommandLineProgram.java @@ -27,7 +27,7 @@ import java.util.Enumeration; *

*

* This class is our implementation of the command line parser, similar to Pickard's. We instead - * support GNU style command line arguements, and use this class to setup the global parser. + * support GNU style command line arguments, and use this class to setup the global parser. */ public abstract class CommandLineProgram {