aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2008-12-05 11:24:28 -0600
committerJoshua Peek <josh@joshpeek.com>2008-12-05 11:24:28 -0600
commit731dcd84048ef259684cc8005101f65d1941e495 (patch)
tree02b05367d813fccc777885faa06600a355532ba9 /activesupport
parent9c9da6c892d715ca22c3cf51f50deb1d80029c66 (diff)
downloadrails-731dcd84048ef259684cc8005101f65d1941e495.tar.gz
rails-731dcd84048ef259684cc8005101f65d1941e495.tar.bz2
rails-731dcd84048ef259684cc8005101f65d1941e495.zip
Silence server backtrace in rescue templates and log files. Also remove some noise from missing template errors.
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/exception.rb19
1 files changed, 11 insertions, 8 deletions
diff --git a/activesupport/lib/active_support/core_ext/exception.rb b/activesupport/lib/active_support/core_ext/exception.rb
index 73470cbe05..cde0df4153 100644
--- a/activesupport/lib/active_support/core_ext/exception.rb
+++ b/activesupport/lib/active_support/core_ext/exception.rb
@@ -11,10 +11,11 @@ class Exception # :nodoc:
def clean_message
Pathname.clean_within message
end
-
+
TraceSubstitutions = []
- FrameworkRegexp = /generated|vendor|dispatch|ruby|script\/\w+/
-
+ FrameworkStart = /action_controller\/dispatcher\.rb/.freeze
+ FrameworkRegexp = /generated|vendor|dispatch|ruby|script\/\w+/.freeze
+
def clean_backtrace
backtrace.collect do |line|
Pathname.clean_within(TraceSubstitutions.inject(line) do |result, (regexp, sub)|
@@ -22,20 +23,22 @@ class Exception # :nodoc:
end)
end
end
-
+
def application_backtrace
+ before_framework_frame = nil
before_application_frame = true
-
+
trace = clean_backtrace.reject do |line|
+ before_framework_frame ||= (line =~ FrameworkStart)
non_app_frame = (line =~ FrameworkRegexp)
before_application_frame = false unless non_app_frame
- non_app_frame && ! before_application_frame
+ before_framework_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
clean_backtrace.grep FrameworkRegexp
end