Skip to content

Instantly share code, notes, and snippets.

@mhorbul
Created October 18, 2011 18:19
Show Gist options
  • Save mhorbul/1296208 to your computer and use it in GitHub Desktop.
Save mhorbul/1296208 to your computer and use it in GitHub Desktop.
class A
def foo
raise "error from old"
end
end
class A
def new_foo
raise "error from new method"
end
alias_method :old_foo, :foo
alias_method :foo, :new_foo
end
begin
A.new.foo
rescue => e
puts e.backtrace.join("\n") # => stack trace from the new method
end
class A
alias_method :foo, :old_foo
end
begin
A.new.foo
rescue => e
puts e.backtrace.join("\n") # => stack trace from the old method
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment