1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
class Exception alias :clean_message :message TraceSubstitutions = [] def clean_backtrace backtrace.collect do |line| TraceSubstitutions.inject(line) do |line, (regexp, sub)| line.gsub regexp, sub end end end def application_backtrace clean_backtrace.reject { |line| line =~ /(vendor|dispatch|ruby|script\/\w+)/ } end end