Ruby Stuff: Use retry to restart a begin rescue block
February 11th, 2010
I recently needed to be able retry a begin block and was simply nesting begins within begins, then I ran across this little Ruby gym. The retry, http://www.tutorialspoint.com/ruby/ruby_exceptions.htm.
begin
@calendarapi.calendars
rescue Exception => ex
logger.info ex
switch_ssl()
retry
end
Obviously this bit of code could end in a continuous loop so be careful to add a little logic to ensure a clean exit.
Be the first person to leave your comment.