[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Errors in threads

jvivenot

6/18/2006 10:30:00 PM

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.

--
Julien Vivenot

2 Answers

jvivenot

6/18/2006 11:52:00 PM

0

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

jvivenot wrote:
> 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.
>
> --
> Julien Vivenot

Robert Klemme

6/19/2006 8:35:00 AM

0

jvivenot wrote:
> That's OK, i had only been once again stupid.
> The only thing I had to do was running Ruby with -d option...
>
> jvivenot wrote:
>> 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.

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.ht...

Kind regards

robert