From: Jim Weirich Date: 2005-07-30T00:09:24+09:00 Subject: Re: Allow retry to take arguments? Austin Ziegler said: > One problem that I see, Jim. In Daniel's pseudo-code, he can rescue > specific exceptions: > > begin > connect_to_something > rescue NetworkBusyException, TimeoutException > retry(3, 30) or raise > rescue NetworkUnavailableException > retry(5, 60) or raise > end Gah! What is the semantics of that? What if you get a NetworkBusyException, so you want to retry 3 times. But the next time you get a NetworkUnavailable exception. Do you leave it at 3 retries or up it to a max of 5 tries. Or do the tries for each exception count individually, i.e. we could have up to 8 retries, 5 for Unavailable and 3 for Busy/Timeout. Or is a a max of 11 retries because retries for timeout and busy count together. > Yours just allows for one attempt wrapper and doesn't specify what > sort of exceptions can be caught. So use ... attempt([NetworkBusyException, TimeoutException] => [3,30], NetworkUnavailableException => [5, 60]) do connect_to_something end or something like this ... Attempt = RetryController.new do |retry| retry.on NetworkBusyException, TimeoutException, :trys=>3, :timeout=>30 retry.on NetworkUnavailableException, :trys=>5, :timeout=>60 end # ... later in code ... Attempt.call { connect_to_something } All still doable without changing the language. -- -- Jim Weirich jim@weirichhouse.org http://onestepback.org ----------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)