From: Mat Schaffer Date: 2006-06-24T04:33:22+09:00 Subject: Re: Global Exception Rescue On Jun 23, 2006, at 12:07 PM, ara.t.howard@noaa.gov wrote: > On Fri, 23 Jun 2006, James Edward Gray II wrote: > harp:~ > cat env.rb > STDIN.reopen(open(__FILE__)) > at_exit do > e = $! > if e > require 'logger' > Logger.new(STDERR).fatal{ e } > end > end > > > harp:~ > cat a.rb > puts gets > raise 'foobar' > > > harp:~ > ruby -r env.rb a.rb > STDIN.reopen(open(__FILE__)) > F, [2006-06-23T10:04:35.279359 #15389] FATAL -- : foobar > (RuntimeError) > a.rb:2 > a.rb:2: foobar (RuntimeError) > > > note that the original behaviour (dumping to STDERR) is also done. > if you > don't want this add in > > at_exit do > ... > exit! > end > > regards. > > -a Can you explain why you have STDIN.reopen(open(__FILE__)) there? It's really baffling me. I can't figure out just what it's doing. -Mat