From: Alex Fenton Date: 2008-09-18T21:57:29+09:00 Subject: Re: at_exit handler *except* for fatal runtime error synergism wrote: > How do we execute a handler (I assume via at_exit) when a program > terminates *except* when there was a fatal runtime error (e.g. any > error such as "divide by zero" that terminates the program)? Inspect the value of $! (or $ERROR_INFO) in your at_exit handler. This will contain the last exception raised. eg Kernel.at_exit { if $!.kind_of? ZeroDivisionError puts "don't run" else puts "run it" end } 5 / 0 hth a