Skip to content

Instantly share code, notes, and snippets.

@arathunku
Created January 7, 2021 11:15
Show Gist options
  • Save arathunku/363dbcaf9357b4f31bfb82b5f8aea902 to your computer and use it in GitHub Desktop.
Save arathunku/363dbcaf9357b4f31bfb82b5f8aea902 to your computer and use it in GitHub Desktop.
ActiveSupport.on_load(:action_controller_base) do
bc = ActiveSupport::BacktraceCleaner.new
bc.remove_silencers!
bc.add_silencer { |line| line.start_with?(RbConfig::CONFIG["rubylibdir"]) }
bc.add_silencer { |line| line =~ Regexp.union(
*(
%w{ bootsnap railties spring activesupport actionpack zeitwerk thor rack }.
map{|g| /\A#{g} \([\w.]+\) /}
),
/\Abin\/rails/
)}
trace = bc.clean(caller)
puts "Cleaned backtrace:\n\t#{trace.join("\n\t")}\n"
puts "Most probably the cause is: #{trace.first}"
puts "If not - uncomment `raise` at #{__FILE__}:#{__LINE__+1}"
# raise "i can haz full backtrace"
exit(1)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment