3 ms·
Oh, definitely. I didn't mean to diminish the cool things toe_tag does - I just tend to dislike the tendency for novices to just use gems to do things without u
by cheald 12y ago
Oh, definitely. I didn't mean to diminish the cool things toe_tag does - I just tend to dislike the tendency for novices to just use gems to do things without understanding why they work, o I like to point out where solutions can be accomplished in bare Ruby. :)
toe_tag sounds like a great tool for the toolbox, but if the need is "I want to rescue multiple exceptions at once in a DRY fashion", there's no magic needed.
- djur 12y agoUnderstood and agreed, as a fellow "just use Ruby"-ist. Once you've done something a few dozen times or so by hand, you start thinking about whether it might be handy to have a library for it. But as someone who is employed to maintain and improve more than one Ruby app with more than 200 gem dependencies apiece, I can say with certitude that there is such a thing as going too far. I have actually found that even fairly experienced Ruby developers have a limited understanding of how Ruby exceptions work. Usually there's one or two gaps -- like not knowing that `rescue Exception` is a bad idea, or not knowing `rescue => err` works (as opposed to `rescue StandardError => err`), or that multiple rescues can be added to a single begin block (I've seen nested `begin...rescue` constructs for exactly that reason), or that `rescue A, B` works. Or what the return value of `begin...rescue...ensure` is. (Or that `begin...rescue` can take an `else`, which is another example of its shared behavior with `case...when`. I still have yet to see begin-else used in real code, though, and I wouldn't encourage it.) Thank you for the kind words!