[Ruby] Catching an error when using class methods
Ryan Davis
ryand-ruby at zenspider.com
Thu Jul 19 09:18:49 PDT 2007
On Jul 19, 2007, at 07:59 , Ofer Matan wrote:
> I am sorry to have missed the BBQ - but I caught a summer cold/
> cough and
> though it would be better for all concerned if I stay home....
>
> To my question:
>
> Is there an easy way to catch exceptions for all methods in a
> class? I am
> wrapping another class and use its methods in many of my methods
> and would
> like to avoid using begin/rescue in each method.
Sooo... you're just being lazy? Why?
> Are there better solutions now for this ?
Get a better text editor.
Clever code like you linked to is bad.
One thing to point out is that you don't need the begin and extra
level of indentation:
def blah
# ... code
rescue
# ... handler
end
but that's really just 1 line and some spaces. Functionally they're
equivalent.
More information about the Ruby
mailing list