From: Florian Gross Date: 2004-11-26T04:47:57+09:00 Subject: Re: [Q] Catching exceptions at top level Laurent Julliard wrote: > I have sort of a trivial question here that I'm afraid is so simple that > I could not find the answer :-( > > I'd like to be able to catch all unrescued exceptions raised in a Ruby > script in the END block that is executed last before the script > terminates. The goal is to intercept the the exception raised and > process the exception message and stack trace before it is printed I think you can just edit the object that is in $!. If you want a solution without using perlish variables wrap the whole application in a rescue clause like this: begin code more code and so on ... rescue Exception => error do something with error raise # reraise the exception end