Exception Loops

J

Jeff Miller

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
 
J

Joel VanderWerf

Jeff said:
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
undefined local variable or method `session' for main:Object
 
T

Tim Hunter

Jeff said:
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,289
Messages
2,571,435
Members
48,121
Latest member
ColinHibne

Latest Threads

Top