R – How to get error messages from ruby threads

multithreadingruby

I'm having a problem right now where I can't see where my child threads are spitting out error messages which is making it difficult to debug.

eg:

Thread.new{
    a = 1/0
}

Is there any way to have all thread errors print out at stderr?

Best Solution

Set the Thread class' abort_on_exception flag to true.

Alternately, wrap the thread body in a throw/catch block and dump the exception in the catch.