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);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void exitSystemWithSamError(final Exception e) {
|
public static void exitSystemWithSamError(final Throwable t) {
|
||||||
if ( e.getMessage() == null )
|
if ( t.getMessage() == null )
|
||||||
throw new ReviewedStingException("SamException found with no message!", e);
|
throw new ReviewedStingException("SamException found with no message!", t);
|
||||||
|
|
||||||
errorPrintf("------------------------------------------------------------------------------------------%n");
|
errorPrintf("------------------------------------------------------------------------------------------%n");
|
||||||
errorPrintf("A BAM ERROR has occurred (version %s): %n", CommandLineGATK.getVersionNumber());
|
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");
|
errorPrintf("Also, please ensure that your BAM index is not corrupted: delete the current one and regenerate it with 'samtools index'%n");
|
||||||
printDocumentationReference();
|
printDocumentationReference();
|
||||||
errorPrintf("%n");
|
errorPrintf("%n");
|
||||||
errorPrintf("MESSAGE: %s%n", e.getMessage().trim());
|
errorPrintf("MESSAGE: %s%n", t.getMessage().trim());
|
||||||
errorPrintf("------------------------------------------------------------------------------------------%n");
|
errorPrintf("------------------------------------------------------------------------------------------%n");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -101,20 +101,28 @@ public class CommandLineGATK extends CommandLineExecutable {
|
||||||
// TODO: Should Picard exceptions be, in general, UserExceptions or ReviewedStingExceptions?
|
// TODO: Should Picard exceptions be, in general, UserExceptions or ReviewedStingExceptions?
|
||||||
exitSystemWithError(e);
|
exitSystemWithError(e);
|
||||||
} catch (SAMException e) {
|
} catch (SAMException e) {
|
||||||
checkForTooManyOpenFilesProblem(e.getMessage());
|
checkForMaskedUserErrors(e);
|
||||||
exitSystemWithSamError(e);
|
exitSystemWithSamError(e);
|
||||||
} catch (OutOfMemoryError e) {
|
} catch (OutOfMemoryError e) {
|
||||||
exitSystemWithUserError(new UserException.NotEnoughMemory());
|
exitSystemWithUserError(new UserException.NotEnoughMemory());
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
checkForTooManyOpenFilesProblem(t.getMessage());
|
checkForMaskedUserErrors(t);
|
||||||
exitSystemWithError(t);
|
exitSystemWithError(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void checkForTooManyOpenFilesProblem(String message) {
|
private static void checkForMaskedUserErrors(final Throwable t) {
|
||||||
// Special case the "Too many open files" error because it's a common User Error for which we know what to do
|
final String message = t.getMessage();
|
||||||
if ( message != null && message.indexOf("Too many open files") != -1 )
|
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());
|
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