When I spawn a thread with Thread.new{} it looks like any exception that happens in that thread never sees the light of day, and the app just quietly ignores it
+1
A:
Normally, threads are isolated from each other, so exception in one won't terminate the whole application.
But, although I never used them, Thread
class has several abort_on_exception
methods, even with some examples. They should do what you want.
http://corelib.rubyonrails.org/classes/Thread.html
Nikita Rybak
2010-08-02 19:13:57
Awesome! thanks!
Tyler Gillies
2010-08-02 20:29:34
A:
Adding to Nikita's answer, you can also trigger the exception by calling thread.join
on the thread you've generated.
If you run the program with the debug flag on (ruby -d
), then you'll also abort when an unhandled exception is raised in a thread.
Andrew Grimm
2010-08-02 23:55:50