I am learning more and more about ruby and have written a script that times out on occassion (making several API calls).
I know I need to rescue
the exception with something like this:
rescue Timeout::Error => e
# log #{e} for later, maybe
end
My question is where I should place that rescue
block. Since I am making several API calls within multiple loops, would I need to put that block within each API loop? I would prefer to just write the rescue
block once, at the end of the script for example, and have it work inside each loop in the script. I am using ruby 1.9.3.