Chris Cummer
2/12/2008 2:27:00 AM
On 11-Feb-08, at 6:06 PM, Mitch Mitch wrote:
> My suggestion is to change the line to:
>
> rescue RangeError
>
> Which only rescues the error that the author was intending (I
> believe).
>
> Am I missing anything here?
RangeError is generally used only to catch errors with a numerical
range. I think what you're intending here is probably IndexError
however even that isn't correct since
> for i in @observer_peers.dup
> begin
> i.update(*arg)
> rescue
> delete_observer(i)
> end
> end
since I don't believe a for...in loop can exceed the index in this
case unless something else is modifying @observer_peers at the same
time...?
I confess the "for...in" looks mighty strange to me, as I find
"@observer_peers.each do |i|" much easier to read these days.
I'd hazard a guess, from that little chunk of code, that the author's
intention was not to catch bounding errors with the loop but rather to
destroy any observers that were causing critical errors so as to not
have to deal with them. From the sounds of what you describe, it was
working as such as well, though silently destroying someone's stuff
seems just plain rude to me :)
These are all just guesses of course, as I've never used DRb and only
seen the chunk of code you posted. Hope that help.
Regards
Chris