From 0c2016c19a0ea1ced97ab0dccd893432e911f60f Mon Sep 17 00:00:00 2001 From: depristo Date: Thu, 15 Oct 2009 12:07:44 +0000 Subject: [PATCH] Improved error messages -- now easier to read, points to the GATK Error Messages wiki, and avoids double printing of stack traces git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1850 348d0f76-0448-11de-a6fe-93d51630548a --- .../iterators/MergingSamRecordIterator2.java | 10 ++++------ .../utils/cmdLine/CommandLineProgram.java | 18 +++++++++++------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/iterators/MergingSamRecordIterator2.java b/java/src/org/broadinstitute/sting/gatk/iterators/MergingSamRecordIterator2.java index bac7f1c52..265df5879 100644 --- a/java/src/org/broadinstitute/sting/gatk/iterators/MergingSamRecordIterator2.java +++ b/java/src/org/broadinstitute/sting/gatk/iterators/MergingSamRecordIterator2.java @@ -99,15 +99,13 @@ public class MergingSamRecordIterator2 implements CloseableIterator, */ private void checkSortOrder(SAMFileReader reader) { if (this.sortOrder != SAMFileHeader.SortOrder.unsorted && reader.getFileHeader().getSortOrder() != this.sortOrder) { + String msg = String.format("The GATK requires your bam have %s sort order, but your BAM file header %s. Continuing beyond this point is unsafe -- please update your BAM file to have a compatible sort order using samtools sort or Picard MergeBamFiles", + this.sortOrder, reader.getFileHeader().getAttribute("SO") == null ? "is missing the SO sort order flag" : "has an SO flag set to " + reader.getFileHeader().getAttribute("SO")); if (reads.getSafetyChecking()) { - throw new PicardException("Files are not compatible with sort order: " + reader.getFileHeader().getSortOrder() + - " vrs " + this.sortOrder + ". Make sure that the SO flag in your bam file is set (The reader attribute for sort order equals " - + reader.getFileHeader().getAttribute("SO") + " in this case)."); + throw new PicardException(msg); } else if (!warnedUserAboutSortOrder) { warnedUserAboutSortOrder = true; - Utils.warnUser("Files are not compatible with sort order: " + reader.getFileHeader().getSortOrder() + - " vrs " + this.sortOrder + ". Make sure that the SO flag in your bam file is set (The reader attribute for sort order equals " - + reader.getFileHeader().getAttribute("SO") + " in this case)."); + Utils.warnUser(msg); } } diff --git a/java/src/org/broadinstitute/sting/utils/cmdLine/CommandLineProgram.java b/java/src/org/broadinstitute/sting/utils/cmdLine/CommandLineProgram.java index 855e53e62..ff7ccb6e2 100644 --- a/java/src/org/broadinstitute/sting/utils/cmdLine/CommandLineProgram.java +++ b/java/src/org/broadinstitute/sting/utils/cmdLine/CommandLineProgram.java @@ -228,12 +228,12 @@ public abstract class CommandLineProgram { } } - // regardless of what happens next, generate the header information - generateHeaderInformation(clp, args); - // set the default logger level clp.setupLoggerLevel(); + // regardless of what happens next, generate the header information + generateHeaderInformation(clp, args); + // call the execute CommandLineProgram.result = clp.execute(); @@ -249,8 +249,8 @@ public abstract class CommandLineProgram { // we catch all exceptions here. if it makes it to this level, we're in trouble. Let's bail! // TODO: what if the logger is the exception? hmm... logger.fatal("Exception caught by base Command Line Program, with message: " + e.getMessage()); - logger.fatal("with cause: " + e.getCause()); - e.printStackTrace(); + if ( e.getCause() != null ) logger.fatal("with cause: " + e.getCause()); + //e.printStackTrace(); throw new RuntimeException(e); } } @@ -338,8 +338,12 @@ public abstract class CommandLineProgram { */ private static void printExitSystemMsg(final String msg) { System.out.printf("------------------------------------------------------------------------------------------%n"); - System.out.printf("An error has occurred. Please check your command line arguments for any typos or inconsistencies.%n%n"); - System.out.printf("For assistance, please email us at gsahelp@broad.mit.edu, or review our documentation at http://www.broadinstitute.org/gsa/wiki.%n"); + System.out.printf("The following error has occurred:%n%n"); + System.out.printf("%s:%n%n", msg); + System.out.printf("Please check your command line arguments for any typos or inconsistencies.%n"); + System.out.printf("Help for dealing with common GATK error messages can be found at http://www.broadinstitute.org/gsa/wiki/index.php/GATK_Error_Messages%n"); + System.out.printf(" Or see our general docs documentation at http://www.broadinstitute.org/gsa/wiki%n"); + System.out.printf("Please email us at gsahelp@broad.mit.edu to report bugs or with help resolving undocumented issues%n"); } /**