I'm redefining method_missing
for a proxy-style object. I would like to be able to throw a custom NoMethodError
(or some other error if NoMethodError
is a particular problem, I used an ArgumentError
below) to give the caller more information as to why the particular proxy object doesn't have the method.
However, when I try to throw any exception from method_missing
I get into a recursive loop that eventually results in SystemStackError: stack level too deep
.
I would like to be able to do something like this:
class X
define method_missing(symbol, *args)
raise ArgumentError("Here: #{symbol} ")
end
end
x = X.new
x.a # Raise an ArgumentError, not a SystemStackError