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

Jeff M. wrote:

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 undefined local variable or methodsession’ for main:Object

Jeff M. wrote:

end

any suggestions?

Thanks!!

  • Jeff

retry?

thanks guys, thats what I was looking for

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs