0

Is it possible to add more than one rescue in a begin loop and/or a function and still have a next as well for each?

For example:

begin twitter_function

rescue Twitter::Error::RateLimit => error
  next
rescue Twitter::Error::Unauthorized => error
  next
end
marriedjane875
  • 653
  • 2
  • 10
  • 24

1 Answers1

0

Yes, We can do next in begin - rescue loop. We can do this in following manner -

for i in 1..10
  begin
    do_something_that_might_raise_exceptions(i)
  raise ExpectedError1 => error1
    next # do_something_* again, with the next i
  raise ExpectedError2 => error2
    next # do_something_* again, with the next i
  end
end
Amit Suroliya
  • 1,515
  • 1
  • 11
  • 21