Bug fixes to allow us to generate GATKRunReports for very early errors that leave the engine in a corrupt state. Vastly better error handling of common command line problems. Analysis output now notes whether an exception is a a UserException or a StingException

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4278 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
depristo 2010-09-14 22:45:15 +00:00
parent 2be5e862f1
commit 74d4f124b1
2 changed files with 24 additions and 10 deletions

View File

@ -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);

View File

@ -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());
}