method
backtrace
ruby latest stable - Class:
Exception
backtrace()public
Returns any backtrace associated with the exception. The backtrace is an array of strings, each containing either "filename:lineNo: in `method"‘ or "filename:lineNo."
def a raise "boom" end def b a() end begin b() rescue => detail print detail.backtrace .join("\n") end
produces:
prog.rb:2:in `a' prog.rb:6:in `b' prog.rb:10
static VALUE
exc_backtrace(VALUE exc)
{
VALUE obj;
obj = rb_attr_get(exc, id_bt);
if (rb_backtrace_p(obj)) {
obj = rb_backtrace_to_str_ary(obj);
/* rb_ivar_set(exc, id_bt, obj); */
}
return obj;
}