diff options
Diffstat (limited to 'activesupport/lib/active_support/core_ext/exception.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/exception.rb | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/activesupport/lib/active_support/core_ext/exception.rb b/activesupport/lib/active_support/core_ext/exception.rb index cde0df4153..b594fbae8e 100644 --- a/activesupport/lib/active_support/core_ext/exception.rb +++ b/activesupport/lib/active_support/core_ext/exception.rb @@ -1,15 +1,19 @@ module ActiveSupport - if RUBY_VERSION >= '1.9' - FrozenObjectError = RuntimeError - else - FrozenObjectError = TypeError - end + FrozenObjectError = RUBY_VERSION < '1.9' ? TypeError : RuntimeError end # TODO: Turn all this into using the BacktraceCleaner. class Exception # :nodoc: + # Clean the paths contained in the message. + def self.clean_paths(string) + require 'pathname' unless defined? Pathname + string.gsub(%r{[\w. ]+(/[\w. ]+)+(\.rb)?(\b|$)}) do |path| + Pathname.new(path).cleanpath + end + end + def clean_message - Pathname.clean_within message + Exception.clean_paths(message) end TraceSubstitutions = [] @@ -18,9 +22,10 @@ class Exception # :nodoc: def clean_backtrace backtrace.collect do |line| - Pathname.clean_within(TraceSubstitutions.inject(line) do |result, (regexp, sub)| + substituted = TraceSubstitutions.inject(line) do |result, (regexp, sub)| result.gsub regexp, sub - end) + end + Exception.clean_paths(substituted) end end |