On 18.09.2008 18:31, DMisener wrote: > On Sep 18, 1:03 pm, Robert Klemme <shortcut... / googlemail.com> wrote: >> 2008/9/18 synergism <synerg... / gmail.com>: >> >>> 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)? >> You can use exit! for this: >> > ... >> -e:1: Foo (RuntimeError) >> 18:09:21 ~$ ruby -e 'at_exit { puts "exiting" }; exit! 1' >> 18:09:27 ~$ >> >> Catch specific errors and use exit! to exit the program. Then your >> handlers won't be invoked. >> > > But out above example we want to suppress the file rename for any > "unanticipated exception" -- which > is just the opposite of the solution you presented :=). Oh, come on. You can easily use that information to build what you want. robert