Skip to content

Commit 2026c0a

Browse files
committedJul 19, 2016
Avoid setting Exception#cause to itself.
1 parent e243e50 commit 2026c0a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎core/zed.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1431,7 +1431,7 @@ def raise(exc=undefined, msg=undefined, ctx=nil, cause: nil)
14311431
if undefined.equal? exc
14321432
exc = $!
14331433
exc = RuntimeError.new("No current exception") unless exc
1434-
exc.cause = cause unless exc.cause
1434+
exc.cause = cause unless exc.cause or exc == cause
14351435
else
14361436
if exc.respond_to? :exception
14371437
if undefined.equal? msg
@@ -1446,8 +1446,8 @@ def raise(exc=undefined, msg=undefined, ctx=nil, cause: nil)
14461446
raise ::TypeError, 'exception class/object expected'
14471447
end
14481448

1449-
exc.cause = cause unless exc.cause
1450-
exc.cause = $! unless exc.cause
1449+
exc.cause = cause unless exc.cause or exc == cause
1450+
exc.cause = $! unless exc.cause or exc == $!
14511451
end
14521452

14531453
if ctx.kind_of? Array

0 commit comments

Comments
 (0)
Please sign in to comment.