From e714b25723b674bb6d66af40ea9047166907616b Mon Sep 17 00:00:00 2001 From: Nicholas Seckar Date: Tue, 4 Apr 2006 19:37:29 +0000 Subject: Update the diagnostics template skip the useless '' text. Fix symbol extensions test case. Clean paths inside of exception messages and traces. Add Pathname.clean_within for cleaning all the paths inside of a string. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4158 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../lib/active_support/core_ext/exception.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'activesupport/lib/active_support/core_ext/exception.rb') diff --git a/activesupport/lib/active_support/core_ext/exception.rb b/activesupport/lib/active_support/core_ext/exception.rb index 0b65af7bf8..2e3965117b 100644 --- a/activesupport/lib/active_support/core_ext/exception.rb +++ b/activesupport/lib/active_support/core_ext/exception.rb @@ -1,25 +1,30 @@ -class Exception - alias :clean_message :message +class Exception # :nodoc: + def clean_message + Pathname.clean_within message + end TraceSubstitutions = [] - FrameworkRegexp = /generated_code|vendor|dispatch|ruby|script\/\w+/ + FrameworkRegexp = /generated|vendor|dispatch|ruby|script\/\w+/ def clean_backtrace backtrace.collect do |line| - TraceSubstitutions.inject(line) do |line, (regexp, sub)| + Pathname.clean_within(TraceSubstitutions.inject(line) do |line, (regexp, sub)| line.gsub regexp, sub - end + end) end end def application_backtrace before_application_frame = true - clean_backtrace.reject do |line| - non_app_frame = !! (line =~ FrameworkRegexp) + trace = clean_backtrace.reject do |line| + non_app_frame = (line =~ FrameworkRegexp) before_application_frame = false unless non_app_frame non_app_frame && ! before_application_frame end + + # If we didn't find any application frames, return an empty app trace. + before_application_frame ? [] : trace end def framework_backtrace -- cgit v1.2.3