# Stop and display traceback when thread throws an exception

**URL:** <https://www.ruby-forum.com/t/stop-and-display-traceback-when-thread-throws-an-exception/195356>\
**Category:** Ruby\
**Created:** [September 22, 2010, 4:33am UTC](https://www.ruby-forum.com/t/stop-and-display-traceback-when-thread-throws-an-exception/195356 "2010-09-22T04:33:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [September 22, 2010, 4:33am UTC](https://www.ruby-forum.com/t/stop-and-display-traceback-when-thread-throws-an-exception/195356/1 "2010-09-22T04:33:37Z")

</div>

Is there a way to stop all threads and display traceback when any thread  
(especially a thread that is not the main thread) throws an exception?

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [September 22, 2010, 9:49am UTC](https://www.ruby-forum.com/t/stop-and-display-traceback-when-thread-throws-an-exception/195356/2 "2010-09-22T09:49:42Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Am 22.09.2010 04:24, schrieb Ralph S.:

> Is there a way to stop all threads and display traceback when any thread (especially a thread that is not the main thread) throws an exception?

You can either run ruby with the -d (or --debug) switch or call this  
somewhere in your code:

Thread.abort\_on\_exception = true

Vale,  
Quintus  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.10 (GNU/Linux)  
Comment: Using GnuPG with Mozilla - [http://enigmail.mozdev.org/](http://enigmail.mozdev.org/)

iEYEARECAAYFAkyZtOQACgkQDYShvwAbcNmA6wCgiwr/HXLnEKqYB33KRW7qlz7U  
oPIAn3aUa9O+EQi/7XyiATJHO/F2RdvK  
=aPOP  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [September 22, 2010, 10:03am UTC](https://www.ruby-forum.com/t/stop-and-display-traceback-when-thread-throws-an-exception/195356/3 "2010-09-22T10:03:45Z")

</div>

in my experience the ruby-debug debugger (1.8.7) goes all haywire when  
you’re working with threads.

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [September 22, 2010, 2:43pm UTC](https://www.ruby-forum.com/t/stop-and-display-traceback-when-thread-throws-an-exception/195356/4 "2010-09-22T14:43:37Z")

</div>

Quintus,

Wednesday, September 22, 2010, 1:48:58 AM, you wrote:

Q\> -----BEGIN PGP SIGNED MESSAGE-----  
Q\> Hash: SHA1

Q\> Am 22.09.2010 04:24, schrieb Ralph S.:

> > Is there a way to stop all threads and display traceback when any thread (especially a thread that is not the main thread) throws an exception?

Q\> You can either run ruby with the -d (or --debug) switch or call this  
Q\> somewhere in your code:

Q\> Thread.abort\_on\_exception = true

Q\> Vale,  
Q\> Quintus

That was exactly what I was looking for. Thank you!
