Exception Loops

Hello,
I have an exception statement that needs to loop if it fails...
something like this:

begin
  contacts_folder = session.GetDefaultFolder(5)
  rescue Exception
  (GO BACK AND TRY AGAIN)
  else
   blah blah blah
end

any suggestions?

Thanks!!
- Jeff

···

--
Posted via http://www.ruby-forum.com/.

Jeff Miller wrote:

Hello,
I have an exception statement that needs to loop if it fails...
something like this:

begin
  contacts_folder = session.GetDefaultFolder(5)
  rescue Exception
  (GO BACK AND TRY AGAIN)
  else
   blah blah blah
end

any suggestions?

Easy, use retry:

begin
   contacts_folder = session.GetDefaultFolder(5)
rescue Exception => ex
   puts ex
   unless $tried
     $tried = true
     retry
   end
end

__END__

Output:

undefined local variable or method `session' for main:Object

···

--
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

Jeff Miller wrote:

Hello,
I have an exception statement that needs to loop if it fails...
something like this:

begin
  contacts_folder = session.GetDefaultFolder(5)
  rescue Exception
  (GO BACK AND TRY AGAIN)
  else
   blah blah blah
end

any suggestions?

Thanks!!
- Jeff

retry?

···

--
RMagick: http://rmagick.rubyforge.org/
RMagick 2: http://rmagick.rubyforge.org/rmagick2.html

thanks guys, thats what I was looking for

···

--
Posted via http://www.ruby-forum.com/.