[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: Catching thread exceptions

Robert Klemme

9/8/2003 8:27:00 AM


Although a little late I try to answer that one.

"Steve Tuckner" <STUCKNER@MULTITECH.COM> schrieb im Newsbeitrag
news:00ed01c35ddb$fe568590$6904a8c0@multitech.prv...
> Why is false by default? In what case would you want an exception to
> propagate to the top of a thread and kill it SILENTLY and then keep
running?

IMHO this is the setting that minimally affects stability of a program.
Imagine a server that spawns threads for requests. If any of those
threads dies due to some error you don't want the whole server to stop.
The proper way to do it is IMHO to handle errors from within the thread:

Thread.new do
begin
raise "aa"
rescue => e
$stderr.puts "ERROR: #{e}"
else
$stdout.puts "fine"
end
end

> Why doesn't it at least print something out if it isn't going to kill
the
> program?

That's another story and possibly a good suggestion: have ruby print a
message to STDERR if a thread terminates with an uncaught exception.

Regards

robert