Uncaught exceptions

hi!

is there a way to catch uncaught exceptions globally for a
ruby app? i would like to have some functionality executed (sending
a report email, etc) whenever a exception can not be caught..

thanks a lot!

ciao!
florian

The simplest way is to catch the exception at the topmost level of your
application.

If for some reason you cannot do that, you can use at_exit or END; the
uncaught exception will be in $! (worked for me in 1.6.8, 1.8.1 and
latest CVS -- didn't work in 1.8.0, though). However, unless you are
using latest CVS, the exception will be printed before the block is
called, so there's no way I know of using this mechanism to inhibit
printing the exception to stderr.

Paul

ยทยทยท

On Sat, Jul 03, 2004 at 08:06:36PM +0900, Florian Weber wrote:

is there a way to catch uncaught exceptions globally for a
ruby app? i would like to have some functionality executed (sending
a report email, etc) whenever a exception can not be caught..