Handle RuntimeExceptions thrown by Picard that are really User Errors. I will add unit tests for these as best I can later.
This commit is contained in:
parent
ae08d35138
commit
4c730542f0
|
|
@ -369,9 +369,9 @@ 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);
|
||||
public static void exitSystemWithSamError(final Throwable t) {
|
||||
if ( t.getMessage() == null )
|
||||
throw new ReviewedStingException("SamException found with no message!", t);
|
||||
|
||||
errorPrintf("------------------------------------------------------------------------------------------%n");
|
||||
errorPrintf("A BAM ERROR has occurred (version %s): %n", CommandLineGATK.getVersionNumber());
|
||||
|
|
@ -383,7 +383,7 @@ public abstract class CommandLineProgram {
|
|||
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("MESSAGE: %s%n", t.getMessage().trim());
|
||||
errorPrintf("------------------------------------------------------------------------------------------%n");
|
||||
System.exit(1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,20 +101,28 @@ public class CommandLineGATK extends CommandLineExecutable {
|
|||
// TODO: Should Picard exceptions be, in general, UserExceptions or ReviewedStingExceptions?
|
||||
exitSystemWithError(e);
|
||||
} catch (SAMException e) {
|
||||
checkForTooManyOpenFilesProblem(e.getMessage());
|
||||
checkForMaskedUserErrors(e);
|
||||
exitSystemWithSamError(e);
|
||||
} catch (OutOfMemoryError e) {
|
||||
exitSystemWithUserError(new UserException.NotEnoughMemory());
|
||||
} catch (Throwable t) {
|
||||
checkForTooManyOpenFilesProblem(t.getMessage());
|
||||
checkForMaskedUserErrors(t);
|
||||
exitSystemWithError(t);
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkForTooManyOpenFilesProblem(String message) {
|
||||
// Special case the "Too many open files" error because it's a common User Error for which we know what to do
|
||||
if ( message != null && message.indexOf("Too many open files") != -1 )
|
||||
private static void checkForMaskedUserErrors(final Throwable t) {
|
||||
final String message = t.getMessage();
|
||||
if ( message == null )
|
||||
return;
|
||||
|
||||
// we know what to do about the common "Too many open files" error
|
||||
if ( message.indexOf("Too many open files") != -1 )
|
||||
exitSystemWithUserError(new UserException.TooManyOpenFiles());
|
||||
|
||||
// Malformed BAM looks like a SAM file
|
||||
if ( message.indexOf("Cannot use index file with textual SAM file") != -1 )
|
||||
exitSystemWithSamError(t);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue