From: yermej Date: 2008-04-03T09:00:18+09:00 Subject: Re: How to use "retry" into two deep begin/rescue/end ? On Apr 2, 6:27 pm, Iņaki Baz Castillo wrote: > Hi, in the code below I want "retry/break/XXXXX" (undefined) in SECOND BEGIN > to go back to FIRST BEGIN when "raise" instead of SECOND BEGIN but it goes to > SECOND BEGIN. > > I think it's the expected behaviour but maybe there is a way to get what I > want, is it possible? Can you combine the two? > class MyTcpServer < GServer > > def serve(io) > > loop do > begin # FIRST BEGIN > puts "welcome" > ... > ... > raise > ... > ... > rescue NameError # or whatever class of error you want to catch > $stderr.print "serve(io) ERROR: " + $! rescue # most other stuff > puts "ERROR" > retry/break/return/XXXXX # Restart from FIRST > end > end # loop do > > end # def serve(io) > ------------------------------------------------------------ > > Thanks a lot. > > -- > Iņaki Baz Castillo