From f6aa95685dafef8ab987a03ad3203c59a43a2878 Mon Sep 17 00:00:00 2001 From: Eric Banks Date: Mon, 2 Apr 2012 22:46:56 -0400 Subject: [PATCH] OutOfMemory exceptions are User Errors --- .../src/org/broadinstitute/sting/gatk/CommandLineGATK.java | 5 +++-- .../sting/utils/exceptions/UserException.java | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/CommandLineGATK.java b/public/java/src/org/broadinstitute/sting/gatk/CommandLineGATK.java index 9c59ffe9a..70c6bc734 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/CommandLineGATK.java +++ b/public/java/src/org/broadinstitute/sting/gatk/CommandLineGATK.java @@ -100,10 +100,11 @@ public class CommandLineGATK extends CommandLineExecutable { } catch(PicardException e) { // TODO: Should Picard exceptions be, in general, UserExceptions or ReviewedStingExceptions? exitSystemWithError(e); - } - catch (SAMException e) { + } catch (SAMException e) { checkForTooManyOpenFilesProblem(e.getMessage()); exitSystemWithSamError(e); + } catch (OutOfMemoryError e) { + exitSystemWithUserError(new UserException.NotEnoughMemory()); } catch (Throwable t) { checkForTooManyOpenFilesProblem(t.getMessage()); exitSystemWithError(t); diff --git a/public/java/src/org/broadinstitute/sting/utils/exceptions/UserException.java b/public/java/src/org/broadinstitute/sting/utils/exceptions/UserException.java index d625cec20..f513b3345 100755 --- a/public/java/src/org/broadinstitute/sting/utils/exceptions/UserException.java +++ b/public/java/src/org/broadinstitute/sting/utils/exceptions/UserException.java @@ -107,6 +107,12 @@ public class UserException extends ReviewedStingException { } } + public static class NotEnoughMemory extends UserException { + public NotEnoughMemory() { + super(String.format("There was a failure because you did not provide enough memory to run this program. See the -Xmx JVM argument to adjust the maximum heap size provided to Java")); + } + } + public static class ErrorWritingBamFile extends UserException { public ErrorWritingBamFile(String message) { super(String.format("An error occurred when trying to write the BAM file. Usually this happens when there is not enough space in the directory to which the data is being written (generally the temp directory) or when your system's open file handle limit is too small. To tell Java to use a bigger/better file system use -Djava.io.tmpdir=X on the command line. The exact error was %s", message));