From: Han Holl Date: 2002-06-19T04:34:31+09:00 Subject: Re: Debug.rb and exceptions Ned Konz wrote: >On Tuesday 18 June 2002 11:00 am, Han Holl wrote: > > >>Ned Konz wrote: >> >> >>>Easy: catch the Errno::EXDEV and instead do a copy followed by a >>>delete of the original. >>> >>> >>That is not what I meant at all. What you propose is exactly what >>ftools.rb does. My question: is it impossible to use the debugger >>with software that uses begin - rescue in Python style ? >> >> > >Sorry, I misunderstood. > >From my reading of debug.rb, it should be possible. If you look at the >trace_func, you'll see that 'raise' conditions are handled by >excn_handle(), which does nothing (other than printing a trace to >stdout) if you don't have a catchpoint set. > >Of course, you have to get rid of the default catchpoint on >StandardError if you want to ignore any of these. > >So if you start up the debugger with (say) > >cat SystemExit > >then it won't break for any exception other than one that's derived >from SystemExit. You could define your own exception if you wanted to >really make sure that you didn't catch anything. > >Here's an example program (which I called xx.rb): > > >begin > puts "before" > raise StandardError > puts "after" >rescue StandardError > puts "caught" >end > > >And here's my debug session: > >$ ruby -rdebug xx.rb >Debug.rb >Emacs support available. > >xx.rb:8:end >(rdb:1) cat SystemExit >Set catchpoint SystemExit. >(rdb:1) c >before >xx.rb:4: `StandardError' (StandardError) >caught > > Yes, this works. You get a lot of disconcerting error messages, but it does indeed work. I guess I didn't quite get what a catchpoint is. Documentation on debug.rb is scarce indeed. Thanks for your help, Han