This would be handy with some of my class methods for composing exception messages...??
I think the standard thing to do is to munge Exception's backtrace:
def other_method
raise
end
def what_method
other_method
end
begin
what_method
rescue
puts $!.backtrace[0].split(" ")[1][1..-2]
end
At least that is the sort of thing I have been resorting to; if there is
a better way I'd like to know about it! m.
···
Xeno Campanoli <xeno.campanoli@gmail.com> wrote:
This would be handy with some of my class methods for composing exception
messages...??
This would be handy with some of my class methods for composing exception
messages...??
maybe you can call caller and it will tell you who you are
eg,
def whoami
caller[0]
end
=> nil
def m
whoami
end
=> nil
m
=> "(irb):62:in `m'"
···
On Thu, Jun 11, 2009 at 9:37 AM, Xeno Campanoli<xeno.campanoli@gmail.com> wrote:
It Ruby 1.9, __callee__ (or __method__) will return the name of the current method as a symbol.
Gary Wright
···
On Jun 10, 2009, at 9:37 PM, Xeno Campanoli wrote:
This would be handy with some of my class methods for composing exception messages...??