From: Logan Capaldo Date: 2006-08-16T12:59:07+09:00 Subject: Re: begin...rescue...retry next? On Aug 15, 2006, at 10:26 PM, Joe Ruby wrote: > Is there some way to do this in Ruby? > > begin > # do stuff, uh-oh an exception gets raised > rescue > retry next > end > > There's 'retry' which returns to the same statement that threw the > exception, but I'd like execution to resume at the next statement > following it. > > Thanks, > Joe > > -- > Posted via http://www.ruby-forum.com/. > If you know only expression X will raise the exception you can use the modifier form some_code some_exception_raising_call rescue nil # This is evil continue_blissfully_unaware_of_whether_an_exception_was_raised Also retry does not return to the statement that raised the exception, it jumps to the begin begin # retry will put you here some_code some_more_code raise_an_exception even_more_code rescue retry end