Skip to content

Commit 4c6e975

Browse files
chrisseatoneregon
authored andcommitted
New spec for rescuing Exception#exception
1 parent 5667e6c commit 4c6e975

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

spec/ruby/core/exception/exception_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,22 @@
6666
e2.message.should == "message"
6767
end
6868

69+
it "when raised will be rescued as the new exception" do
70+
begin
71+
begin
72+
raised_first = StandardError.new('first')
73+
raise raised_first
74+
rescue => caught_first
75+
raised_second = raised_first.exception('second')
76+
raise raised_second
77+
end
78+
rescue => caught_second
79+
end
80+
81+
raised_first.should == caught_first
82+
raised_second.should == caught_second
83+
end
84+
6985
class CustomArgumentError < StandardError
7086
attr_reader :val
7187
def initialize(val)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fails:Exception#exception when raised will be rescued as the new exception

0 commit comments

Comments
 (0)