Last active
April 15, 2021 18:44
-
-
Save JoshCheek/65b877c7b1f8d974d2d1c474200b2ba6 to your computer and use it in GitHub Desktop.
Reproducing pry-exception_explorer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'binding_of_caller' | |
require 'pry' | |
require 'pry-stack_explorer' | |
TracePoint.trace(:raise) do |tp| | |
next unless tp.path == __FILE__ # <-- correct for this example, not necessarily for your use case | |
# next unless tp.path.start_with? Rails.root.to_s # <-- might be what you want | |
tp.binding.pry | |
end | |
def alpha | |
name = "john" | |
beta | |
puts name | |
end | |
def beta | |
x = "john" | |
gamma(x) | |
end | |
def gamma(x) | |
raise ArgumentError, "x must be a number!" if !x.is_a?(Numeric) # ~> ArgumentError: x must be a number! | |
puts "2 * x = #{2 * x}" | |
end | |
alpha |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment