Skip to content

Instantly share code, notes, and snippets.

@JoshCheek
Last active April 15, 2021 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshCheek/65b877c7b1f8d974d2d1c474200b2ba6 to your computer and use it in GitHub Desktop.
Save JoshCheek/65b877c7b1f8d974d2d1c474200b2ba6 to your computer and use it in GitHub Desktop.
Reproducing pry-exception_explorer
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