From: Laurent Julliard Date: 2004-11-27T16:47:59+09:00 Subject: Re: [Q] Catching exceptions at top level Kaspar Schiess wrote: > Laurent Julliard wrote in news:41A654AB.1070002 > @moldus.org: > > >>The problem is that I must leave the original file containing the code >>unchanged so it has to be a mechanism that i can include with a piece >>of code added at runtime with a -r option > > > The solution was there, but I will make that explicit: > > catcher.rb --------------------------------------- > END { > puts 'exception has happened.' > p $! > } > ----------------------------------------------------- > > test.rb --------------------------------------------- > raise 'dodah' > ----------------------------------------------------- > > Call as > ruby -rcatcher test.rb > > gives you > exception has happened. > # > test.rb:1: dodah (RuntimeError) > > > yours, kaspar > > hand manufactured code - www.tua.ch/ruby > > > This is exactly what I was lloking for and as I suspected when I first asked the question the answer wass almost obvious :-) Thanks again Laurent -- Laurent JULLIARD http://www.moldus.org/~laurent