X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=vendor%2Frails%2Factivesupport%2Flib%2Factive_support%2Fcore_ext%2Fexception.rb;fp=vendor%2Frails%2Factivesupport%2Flib%2Factive_support%2Fcore_ext%2Fexception.rb;h=57c85683345810abc0f488fdceea80c0437bfb11;hb=d115f2e23823271635bad69229a42cd8ac68debe;hp=0000000000000000000000000000000000000000;hpb=37cb670bf3ddde90b214e591f100ed4446469484;p=depot.git diff --git a/vendor/rails/activesupport/lib/active_support/core_ext/exception.rb b/vendor/rails/activesupport/lib/active_support/core_ext/exception.rb new file mode 100644 index 0000000..57c8568 --- /dev/null +++ b/vendor/rails/activesupport/lib/active_support/core_ext/exception.rb @@ -0,0 +1,41 @@ +module ActiveSupport + if RUBY_VERSION >= '1.9' + FrozenObjectError = RuntimeError + else + FrozenObjectError = TypeError + end +end + +class Exception # :nodoc: + def clean_message + Pathname.clean_within message + end + + TraceSubstitutions = [] + FrameworkRegexp = /generated|vendor|dispatch|ruby|script\/\w+/ + + def clean_backtrace + backtrace.collect do |line| + Pathname.clean_within(TraceSubstitutions.inject(line) do |result, (regexp, sub)| + result.gsub regexp, sub + end) + end + end + + def application_backtrace + before_application_frame = true + + 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 + clean_backtrace.grep FrameworkRegexp + end +end