Changed most BAMSchedule ReviewedStingExceptions to UserExceptions
-- As these represent the bulk of the StingExceptions coming from BAMSchedule and are caused by simple problems like the user providing bad input tmp directories, etc.
This commit is contained in:
parent
f9e8e82e33
commit
0b29d54937
|
|
@ -31,6 +31,7 @@ import net.sf.samtools.GATKChunk;
|
||||||
import net.sf.samtools.util.CloseableIterator;
|
import net.sf.samtools.util.CloseableIterator;
|
||||||
import org.broadinstitute.sting.utils.GenomeLoc;
|
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||||
|
import org.broadinstitute.sting.utils.exceptions.StingException;
|
||||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
@ -193,7 +194,28 @@ public class BAMSchedule implements CloseableIterator<BAMScheduleEntry> {
|
||||||
scheduleFileChannel.close();
|
scheduleFileChannel.close();
|
||||||
}
|
}
|
||||||
catch(IOException ex) {
|
catch(IOException ex) {
|
||||||
throw new ReviewedStingException("Unable to close schedule file.");
|
throw makeIOFailureException(true, "Unable to close schedule file.", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience routine for creating UserExceptions
|
||||||
|
* @param wasWriting
|
||||||
|
* @param message
|
||||||
|
* @param e
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private final StingException makeIOFailureException(final boolean wasWriting, final String message, final Exception e) {
|
||||||
|
if ( wasWriting ) {
|
||||||
|
if ( e == null )
|
||||||
|
return new UserException.CouldNotCreateOutputFile(scheduleFile, message);
|
||||||
|
else
|
||||||
|
return new UserException.CouldNotCreateOutputFile(scheduleFile, message, e);
|
||||||
|
} else {
|
||||||
|
if ( e == null )
|
||||||
|
return new UserException.CouldNotReadInputFile(scheduleFile, message);
|
||||||
|
else
|
||||||
|
return new UserException.CouldNotReadInputFile(scheduleFile, message, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -297,7 +319,7 @@ public class BAMSchedule implements CloseableIterator<BAMScheduleEntry> {
|
||||||
return scheduleFileChannel.read(buffer);
|
return scheduleFileChannel.read(buffer);
|
||||||
}
|
}
|
||||||
catch(IOException ex) {
|
catch(IOException ex) {
|
||||||
throw new ReviewedStingException("Unable to read data from BAM schedule file..",ex);
|
throw makeIOFailureException(false, "Unable to read data from BAM schedule file.", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -305,10 +327,10 @@ public class BAMSchedule implements CloseableIterator<BAMScheduleEntry> {
|
||||||
try {
|
try {
|
||||||
scheduleFileChannel.write(buffer);
|
scheduleFileChannel.write(buffer);
|
||||||
if(buffer.remaining() > 0)
|
if(buffer.remaining() > 0)
|
||||||
throw new ReviewedStingException("Unable to write entire buffer to file.");
|
throw makeIOFailureException(true, "Unable to write entire buffer to file.", null);
|
||||||
}
|
}
|
||||||
catch(IOException ex) {
|
catch(IOException ex) {
|
||||||
throw new ReviewedStingException("Unable to write data to BAM schedule file.",ex);
|
throw makeIOFailureException(true, "Unable to write data to BAM schedule file.", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -321,7 +343,7 @@ public class BAMSchedule implements CloseableIterator<BAMScheduleEntry> {
|
||||||
return scheduleFileChannel.position();
|
return scheduleFileChannel.position();
|
||||||
}
|
}
|
||||||
catch(IOException ex) {
|
catch(IOException ex) {
|
||||||
throw new ReviewedStingException("Unable to retrieve position of BAM schedule file.",ex);
|
throw makeIOFailureException(false, "Unable to retrieve position of BAM schedule file.", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -334,7 +356,7 @@ public class BAMSchedule implements CloseableIterator<BAMScheduleEntry> {
|
||||||
scheduleFileChannel.position(position);
|
scheduleFileChannel.position(position);
|
||||||
}
|
}
|
||||||
catch(IOException ex) {
|
catch(IOException ex) {
|
||||||
throw new ReviewedStingException("Unable to position BAM schedule file.",ex);
|
throw makeIOFailureException(false, "Unable to position BAM schedule file.",ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,10 @@ public class UserException extends ReviewedStingException {
|
||||||
super(String.format("Couldn't write file %s because %s with exception %s", file.getAbsolutePath(), message, e.getMessage()));
|
super(String.format("Couldn't write file %s because %s with exception %s", file.getAbsolutePath(), message, e.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CouldNotCreateOutputFile(File file, String message) {
|
||||||
|
super(String.format("Couldn't write file %s because %s", file.getAbsolutePath(), message));
|
||||||
|
}
|
||||||
|
|
||||||
public CouldNotCreateOutputFile(String filename, String message, Exception e) {
|
public CouldNotCreateOutputFile(String filename, String message, Exception e) {
|
||||||
super(String.format("Couldn't write file %s because %s with exception %s", filename, message, e.getMessage()));
|
super(String.format("Couldn't write file %s because %s with exception %s", filename, message, e.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue