From: Joel VanderWerf Date: 2004-12-20T15:45:10+09:00 Subject: Re: threads and errors Charles Mills wrote: > What techniques are available for handling errors that occur in > threads? > > For example how do I find out that an error occured in t below? > > t = Thread.new { raise "error" } > > I need to be able to check on the error status of threads from their > parent. Something like the following would be ideal - but I know this > won't do what I want: > > begin > Thread.new { raise "error"} > rescue > puts $! # in a strange world prints "error", but in actuality does > nothing > end Another approach: begin Thread.new(Thread.current) do |th| begin raise "error" rescue => e th.raise e end end rescue => e p e end