Ruby: Continue a loop after catching an exception
for i in 1..5 begin do_something_that_might_raise_exceptions(i) rescue next # do_something_* again, with the next i endend
to print the exception:
rescue puts $!, $@ next # do_something_* again, with the next iend