mirror of
https://github.com/ruby/ruby.git
synced 2025-09-16 00:54:01 +02:00
parent
8e38d4c78c
commit
8b2e1ca10e
2 changed files with 14 additions and 2 deletions
4
error.c
4
error.c
|
@ -970,11 +970,11 @@ exc_exception(int argc, VALUE *argv, VALUE self)
|
||||||
{
|
{
|
||||||
VALUE exc;
|
VALUE exc;
|
||||||
|
|
||||||
|
argc = rb_check_arity(argc, 0, 1);
|
||||||
if (argc == 0) return self;
|
if (argc == 0) return self;
|
||||||
if (argc == 1 && self == argv[0]) return self;
|
if (argc == 1 && self == argv[0]) return self;
|
||||||
exc = rb_obj_clone(self);
|
exc = rb_obj_clone(self);
|
||||||
exc_initialize(argc, argv, exc);
|
rb_ivar_set(exc, id_mesg, argv[0]);
|
||||||
|
|
||||||
return exc;
|
return exc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -518,6 +518,18 @@ end.join
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_backtrace_by_exception
|
||||||
|
begin
|
||||||
|
line = __LINE__; raise "foo"
|
||||||
|
rescue => e
|
||||||
|
end
|
||||||
|
e2 = e.exception("bar")
|
||||||
|
assert_not_equal(e.message, e2.message)
|
||||||
|
assert_equal(e.backtrace, e2.backtrace)
|
||||||
|
loc = e2.backtrace_locations[0]
|
||||||
|
assert_equal([__FILE__, line], [loc.path, loc.lineno])
|
||||||
|
end
|
||||||
|
|
||||||
Bug4438 = '[ruby-core:35364]'
|
Bug4438 = '[ruby-core:35364]'
|
||||||
|
|
||||||
def test_rescue_single_argument
|
def test_rescue_single_argument
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue