diff --git a/java/src/org/broadinstitute/sting/commandline/ArgumentTypeDescriptor.java b/java/src/org/broadinstitute/sting/commandline/ArgumentTypeDescriptor.java index a7090f299..c50a20f4a 100644 --- a/java/src/org/broadinstitute/sting/commandline/ArgumentTypeDescriptor.java +++ b/java/src/org/broadinstitute/sting/commandline/ArgumentTypeDescriptor.java @@ -338,8 +338,8 @@ class SimpleArgumentTypeDescriptor extends ArgumentTypeDescriptor { // if their argument has no value (null), and there's a default, return that default for the enum value if (defaultEnumeration != null && value == null) result = 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 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. else if (value == null) throw new MissingArgumentValueException(Collections.singleton(createDefaultArgumentDefinition(source))); else @@ -348,12 +348,16 @@ class SimpleArgumentTypeDescriptor extends ArgumentTypeDescriptor { Constructor ctor = type.getConstructor(String.class); result = ctor.newInstance(value); } + } catch (UserException e) { + throw e; } catch (InvocationTargetException e) { - throw new ReviewedStingException("constructFromString:InvocationTargetException: Failed conversion - this is most likely caused by using an incorrect data type (e.g. a double when an int is required)"); + throw new UserException.CommandLineException(String.format("Failed to parse value %s for argument %s. This is most commonly caused by providing an incorrect data type (e.g. a double when an int is required)", + value, source.field.getName())); } catch (Exception e) { throw new DynamicClassResolutionException(String.class, e); } + // TODO FIXME! // WARNING: Side effect! parsingEngine.addTags(result,tags); diff --git a/java/src/org/broadinstitute/sting/gatk/phonehome/GATKRunReport.java b/java/src/org/broadinstitute/sting/gatk/phonehome/GATKRunReport.java index 9d67fdf05..5773381a1 100644 --- a/java/src/org/broadinstitute/sting/gatk/phonehome/GATKRunReport.java +++ b/java/src/org/broadinstitute/sting/gatk/phonehome/GATKRunReport.java @@ -32,6 +32,7 @@ import org.broadinstitute.sting.gatk.arguments.GATKArgumentCollection; import org.broadinstitute.sting.gatk.walkers.Walker; import org.broadinstitute.sting.utils.exceptions.ReviewedStingException; import org.broadinstitute.sting.utils.Utils; +import org.broadinstitute.sting.utils.exceptions.UserException; import org.simpleframework.xml.Element; import org.simpleframework.xml.ElementList; import org.simpleframework.xml.Serializer; @@ -93,23 +94,23 @@ public class GATKRunReport { @Element(required = false, name = "exception") private final ExceptionToXML mException; - @Element(required = true, name = "argument_collection") + @Element(required = false, name = "argument_collection") private final GATKArgumentCollection mCollection; @Element(required = true, name = "working_directory") private String currentPath; @Element(required = true, name = "start_time") - private String startTime; + private String startTime = "ND"; @Element(required = true, name = "end_time") private String endTime; @Element(required = true, name = "run_time") - private long runTime; + private long runTime = 0; @Element(required = true, name = "command_line") - private String cmdLine; + private String cmdLine = "COULD NOT BE DETERMINED"; @Element(required = true, name = "walker_name") private String walkerName; @@ -176,16 +177,21 @@ public class GATKRunReport { // what did we run? id = org.apache.commons.lang.RandomStringUtils.randomAlphanumeric(32); - cmdLine = CommandLineUtils.createApproximateCommandLineArgumentString(engine, walker); + try { + cmdLine = CommandLineUtils.createApproximateCommandLineArgumentString(engine, walker); + } catch (Exception ignore) { } + this.mCollection = engine.getArguments(); walkerName = engine.getWalkerName(walker.getClass()); svnVersion = CommandLineGATK.getVersionNumber(); // runtime performance metrics - startTime = dateFormat.format(engine.getStartTime()); Date end = new java.util.Date(); endTime = dateFormat.format(end); - runTime = (end.getTime() - engine.getStartTime().getTime()) / 1000L; // difference in seconds + if ( engine.getStartTime() != null ) { // made it this far during initialization + startTime = dateFormat.format(engine.getStartTime()); + runTime = (end.getTime() - engine.getStartTime().getTime()) / 1000L; // difference in seconds + } tmpDir = System.getProperty("java.io.tmpdir"); // deal with memory usage @@ -310,8 +316,12 @@ public class GATKRunReport { @Element(required = false, name = "cause") ExceptionToXML cause = null; + @Element(required = false, name = "is-user-exception") + Boolean isUserException; + public ExceptionToXML(Throwable e) { message = e.getMessage(); + isUserException = e instanceof UserException; for (StackTraceElement element : e.getStackTrace()) { stackTrace.add(element.toString()); }