32
32
import htsjdk .samtools .util .zip .DeflaterFactory ;
33
33
34
34
import java .io .File ;
35
- import java .io .FileOutputStream ;
36
35
import java .io .IOException ;
37
36
import java .io .OutputStream ;
38
37
import java .nio .file .Files ;
@@ -300,7 +299,7 @@ public SAMFileWriter makeBAMWriter(final SAMFileHeader header, final boolean pre
300
299
if (this .useAsyncIo ) return new AsyncSAMFileWriter (ret , this .asyncOutputBufferSize );
301
300
else return ret ;
302
301
} catch (final IOException ioe ) {
303
- throw new RuntimeIOException ("Error opening file: " + outputPath .toUri ());
302
+ throw new RuntimeIOException ("Error opening file: " + outputPath .toUri (), ioe );
304
303
}
305
304
}
306
305
@@ -352,7 +351,7 @@ public SAMFileWriter makeSAMWriter(final SAMFileHeader header, final boolean pre
352
351
samFlagFieldOutput );
353
352
return initWriter (header , presorted , ret );
354
353
} catch (final IOException ioe ) {
355
- throw new RuntimeIOException ("Error opening file: " + outputPath .toUri ());
354
+ throw new RuntimeIOException ("Error opening file: " + outputPath .toUri (), ioe );
356
355
}
357
356
}
358
357
@@ -588,7 +587,7 @@ private CRAMFileWriter createCRAMWriterWithSettings(
588
587
indexOS = Files .newOutputStream (indexPath );
589
588
}
590
589
catch (final IOException ioe ) {
591
- throw new RuntimeIOException ("Error creating index file for: " + indexPath .toUri ());
590
+ throw new RuntimeIOException ("Error creating index file for: " + indexPath .toUri (), ioe );
592
591
}
593
592
}
594
593
}
@@ -597,7 +596,7 @@ private CRAMFileWriter createCRAMWriterWithSettings(
597
596
cramOS = IOUtil .maybeBufferOutputStream (Files .newOutputStream (outputFile ), bufferSize );
598
597
}
599
598
catch (final IOException ioe ) {
600
- throw new RuntimeIOException ("Error creating CRAM file: " + outputFile .toUri ());
599
+ throw new RuntimeIOException ("Error creating CRAM file: " + outputFile .toUri (), ioe );
601
600
}
602
601
603
602
final Path md5Path = IOUtil .addExtension (outputFile , ".md5" );
0 commit comments