mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
error.c: Exception#cause
* error.c (exc_cause): captured previous exception. * eval.c (make_exception): capture previous exception automagically. [Feature #8257] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43636 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2fff948394
commit
b050cc5ab9
4 changed files with 35 additions and 0 deletions
|
@ -476,4 +476,19 @@ end.join
|
|||
def test_stackoverflow
|
||||
assert_raise(SystemStackError){m}
|
||||
end
|
||||
|
||||
def test_cause
|
||||
msg = "[Feature #8257]"
|
||||
e = assert_raise(StandardError) {
|
||||
begin
|
||||
raise msg
|
||||
rescue => e
|
||||
assert_nil(e.cause, msg)
|
||||
raise StandardError
|
||||
end
|
||||
}
|
||||
cause = e.cause
|
||||
assert_instance_of(RuntimeError, cause, msg)
|
||||
assert_equal(msg, cause.message, msg)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue