I simply want my method call to suppress all "NoMethodError" exceptions that might arise in the methods it in turn calls.
def foo
begin
bar1
bar2
rescue Exception
return '--'
end
end
But this doesn't work. NoMethodError keeps being raised to the top level.
The exact error is undefined method[]' for nil:NilClass' (NoMethodError)
class Object
def method_missing(meth,*args)
# do whatever you want here
end
end
If you want something less global, you can do this on an narrower class, or even a specific instance:
class << my_object
# and so forth
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With