Skip to content

Commit 647eb55

Browse files
committed
Fix "circular causes" error at re-raising exception when it's caused by implicitly raised exception
1 parent d4bbaaf commit 647eb55

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

core/kernel/raise_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,25 @@
240240
end
241241
end
242242

243+
it "re-raises a previously rescued exception that doesn't have a cause and is a cause of other exception (that wasn't raised explicitly) without setting a cause implicitly" do
244+
begin
245+
begin
246+
raise "Error 1"
247+
rescue => e1
248+
begin
249+
foo # raises NameError
250+
rescue => e2
251+
e1.cause.should == nil
252+
e2.cause.should == e1
253+
raise e1
254+
end
255+
end
256+
rescue => e
257+
e.should == e1
258+
e.cause.should == nil
259+
end
260+
end
261+
243262
it "re-raises a previously rescued exception that has a cause but isn't a cause of any other exception without setting a cause implicitly" do
244263
begin
245264
begin

0 commit comments

Comments
 (0)