Errors in threads

J

jvivenot

Hi.
I don't understand why I don't see error messages when running a code
in a thread ?
How could I change that (and stop execution when an error occured in
the problematic thread)?
Thanks a lot.
 
J

jvivenot

That's OK, i had only been once again stupid.
The only thing I had to do was running Ruby with -d option...
 
R

Robert Klemme

jvivenot said:
That's OK, i had only been once again stupid.
The only thing I had to do was running Ruby with -d option...

Another solution is to do Thread.abort_on_exception=true at the top of
your script.

10:34:57 [~]: ruby -e 'Thread.abort_on_exception=false; Thread.new {
raise "foo" }; sleep 5'
10:35:06 [~]: ruby -e 'Thread.abort_on_exception=true; Thread.new {
raise "foo" }; sleep 5'
-e:1: foo (RuntimeError)
from -e:1
10:35:12 [~]:

See
http://www.ruby-doc.org/core/classes/Thread.html#M001460

Kind regards

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,206
Messages
2,571,069
Members
47,677
Latest member
MoisesKoeh

Latest Threads

Top