From 8571bdbd6766147ece7b9045bcdf019510a71210 Mon Sep 17 00:00:00 2001 From: marcandre Date: Sat, 10 Oct 2009 05:13:08 +0000 Subject: * thread.c (rb_threadptr_execute_interrupts_rec, rb_threadptr_raise): Thread#raise with no argument will now re-raise the current exception if there is one [ruby-core:25367] * eval.c (get_errinfo, rb_rubylevel_thread_errinfo): Getter for current exception for a given thread git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- thread.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'thread.c') diff --git a/thread.c b/thread.c index da4cf9cf30..fc33fe568d 100644 --- a/thread.c +++ b/thread.c @@ -76,6 +76,7 @@ void rb_thread_stop_timer_thread(void); static const VALUE eKillSignal = INT2FIX(0); static const VALUE eTerminateSignal = INT2FIX(1); +static const VALUE eReRaiseSignal = INT2FIX(2); static volatile int system_working = 1; inline static void @@ -1246,6 +1247,10 @@ rb_threadptr_execute_interrupts_rec(rb_thread_t *th, int sched_depth) TH_JUMP_TAG(th, TAG_FATAL); } else { + if (err == eReRaiseSignal) { + err = rb_rubylevel_thread_errinfo(th); + err = rb_make_exception(NIL_P(err) ? 0 : 1, &err); + } rb_exc_raise(err); } } @@ -1312,7 +1317,12 @@ rb_threadptr_raise(rb_thread_t *th, int argc, VALUE *argv) goto again; } - exc = rb_make_exception(argc, argv); + if (argc == 0) { + exc = eReRaiseSignal; + } + else { + exc = rb_make_exception(argc, argv); + } th->thrown_errinfo = exc; rb_threadptr_ready(th); return Qnil; -- cgit v1.2.3