Skip to content

Commit

Permalink
Avoid setting Exception#cause to itself.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Jul 19, 2016
1 parent e243e50 commit 2026c0a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/zed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1431,7 +1431,7 @@ def raise(exc=undefined, msg=undefined, ctx=nil, cause: nil)
if undefined.equal? exc
exc = $!
exc = RuntimeError.new("No current exception") unless exc
exc.cause = cause unless exc.cause
exc.cause = cause unless exc.cause or exc == cause
else
if exc.respond_to? :exception
if undefined.equal? msg
Expand All @@ -1446,8 +1446,8 @@ def raise(exc=undefined, msg=undefined, ctx=nil, cause: nil)
raise ::TypeError, 'exception class/object expected'
end

exc.cause = cause unless exc.cause
exc.cause = $! unless exc.cause
exc.cause = cause unless exc.cause or exc == cause
exc.cause = $! unless exc.cause or exc == $!
end

if ctx.kind_of? Array
Expand Down

0 comments on commit 2026c0a

Please sign in to comment.