diff --git a/ext/bio/bigwig/bigwigext.c b/ext/bio/bigwig/bigwigext.c index 71b6850..509cefa 100644 --- a/ext/bio/bigwig/bigwigext.c +++ b/ext/bio/bigwig/bigwigext.c @@ -185,7 +185,7 @@ bw_get_header(VALUE self) if (!bw) { - rb_raise(rb_eRuntimeError, "The bigWig file handle is not opened!"); + rb_raise(rb_eIOError, "The bigWig file handle is not opened!"); return Qnil; } @@ -225,7 +225,7 @@ bw_get_chroms(int argc, VALUE *argv, VALUE self) if (!bw) { - rb_raise(rb_eRuntimeError, "The bigWig file handle is not opened!"); + rb_raise(rb_eIOError, "The bigWig file handle is not opened!"); return Qnil; } @@ -299,7 +299,7 @@ bw_get_stats(VALUE self, VALUE rb_chrom, VALUE rb_start, VALUE rb_end, VALUE rb_ if (!bw) { - rb_raise(rb_eRuntimeError, "The bigWig file handle is not opened!"); + rb_raise(rb_eIOError, "The bigWig file handle is not opened!"); return Qnil; } @@ -412,7 +412,7 @@ bw_get_values(VALUE self, VALUE rb_chrom, VALUE rb_start, VALUE rb_end) if (!bw) { - rb_raise(rb_eRuntimeError, "The bigWig file handle is not opened!"); + rb_raise(rb_eIOError, "The bigWig file handle is not opened!"); return Qnil; } @@ -484,7 +484,7 @@ bw_get_intervals(VALUE self, VALUE rb_chrom, VALUE rb_start, VALUE rb_end) if (!bw) { - rb_raise(rb_eRuntimeError, "The bigWig file handle is not opened!"); + rb_raise(rb_eIOError, "The bigWig file handle is not opened!"); return Qnil; } @@ -573,7 +573,7 @@ bb_get_entries(VALUE self, VALUE rb_chrom, VALUE rb_start, VALUE rb_end, VALUE r if (!bw) { - rb_raise(rb_eRuntimeError, "The bigBed file handle is not opened!"); + rb_raise(rb_eIOError, "The bigBed file handle is not opened!"); return Qnil; } @@ -671,7 +671,7 @@ bb_get_sql(VALUE self) if (!bw) { - rb_raise(rb_eRuntimeError, "The bigBed file handle is not opened!"); + rb_raise(rb_eIOError, "The bigBed file handle is not opened!"); return Qnil; } @@ -701,7 +701,7 @@ bw_get_file_type(VALUE self) if (!bw) { - rb_raise(rb_eRuntimeError, "The bigWig file handle is not opened!"); + rb_raise(rb_eIOError, "The bigWig file handle is not opened!"); return Qnil; } @@ -724,7 +724,7 @@ bw_is_file_type(VALUE self, int type_check) if (!bw) { - rb_raise(rb_eRuntimeError, "The bigWig file handle is not opened!"); + rb_raise(rb_eIOError, "The bigWig file handle is not opened!"); return Qnil; } diff --git a/test/bigwig_test.rb b/test/bigwig_test.rb index 1f11cce..690d84b 100644 --- a/test/bigwig_test.rb +++ b/test/bigwig_test.rb @@ -47,6 +47,21 @@ def test_closed_with_block assert_equal true, f.closed? end + def test_closed_file_error + bw = Bio::BigWig.new(bwfile) + assert_equal Bio::BigWig, bw.class + bw.close + assert_raises(IOError) { bw.header } + assert_raises(IOError) { bw.chroms } + assert_raises(IOError) { bw.stats("1") } + assert_raises(IOError) { bw.values("1", 0, 3) } + assert_raises(IOError) { bw.intervals("1", 0, 3) } + assert_raises(IOError) { bw.entries("1", 0, 3) } + assert_raises(IOError) { bw.sql } + assert_raises(IOError) { bw.is_bigwig? } + assert_raises(IOError) { bw.is_bigbed? } + end + def test_open_remote skip "Skipping remote test" unless ENV["RUN_REMOTE_TESTS"] == "1"