diff --git a/java/src/org/broadinstitute/sting/commandline/CommandLineProgram.java b/java/src/org/broadinstitute/sting/commandline/CommandLineProgram.java index ed22118e1..b9d717adf 100644 --- a/java/src/org/broadinstitute/sting/commandline/CommandLineProgram.java +++ b/java/src/org/broadinstitute/sting/commandline/CommandLineProgram.java @@ -385,6 +385,25 @@ public abstract class CommandLineProgram { System.exit(1); } + public static void exitSystemWithSamError(final Exception e) { + if ( e.getMessage() == null ) + throw new ReviewedStingException("SamException found with no message!", e); + + errorPrintf("------------------------------------------------------------------------------------------%n"); + errorPrintf("A BAM ERROR has occurred (version %s): %n", CommandLineGATK.getVersionNumber()); + errorPrintf("The invalid inputs must be corrected before the GATK can proceed%n"); + errorPrintf("Please do not post this error to the GATK forum until you have followed the instructions below%n"); + errorPrintf("%n"); + errorPrintf("Please make sure that your BAM file is well-formed by running Picard's validator on it%n"); + errorPrintf("(see http://picard.sourceforge.net/command-line-overview.shtml#ValidateSamFile for details)%n"); + errorPrintf("Also, please ensure that your BAM index is not corrupted: delete the current one and regenerate it with 'samtools index'%n"); + printDocumentationReference(); + errorPrintf("%n"); + errorPrintf("MESSAGE: %s%n", e.getMessage().trim()); + errorPrintf("------------------------------------------------------------------------------------------%n"); + System.exit(1); + } + /** * used to indicate an error occured diff --git a/java/src/org/broadinstitute/sting/gatk/CommandLineGATK.java b/java/src/org/broadinstitute/sting/gatk/CommandLineGATK.java index b3440160a..7982f61e2 100755 --- a/java/src/org/broadinstitute/sting/gatk/CommandLineGATK.java +++ b/java/src/org/broadinstitute/sting/gatk/CommandLineGATK.java @@ -92,6 +92,9 @@ public class CommandLineGATK extends CommandLineExecutable { // We can generate Tribble Exceptions in weird places when e.g. VCF genotype fields are // lazy loaded, so they aren't caught elsewhere and made into User Exceptions exitSystemWithUserError(e); + } catch (net.sf.samtools.SAMException e) { + // Let's try this out and see how it is received by our users + exitSystemWithSamError(e); } catch (Exception e) { exitSystemWithError(e); }