2008-05-18 06:22:34 +02:00
|
|
|
module ActiveSupport
|
|
|
|
if RUBY_VERSION >= '1.9'
|
|
|
|
FrozenObjectError = RuntimeError
|
|
|
|
else
|
|
|
|
FrozenObjectError = TypeError
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2007-01-22 14:43:50 +01:00
|
|
|
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|
|
2007-12-21 08:48:59 +01:00
|
|
|
Pathname.clean_within(TraceSubstitutions.inject(line) do |result, (regexp, sub)|
|
|
|
|
result.gsub regexp, sub
|
2007-01-22 14:43:50 +01:00
|
|
|
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
|
2007-02-09 09:04:31 +01:00
|
|
|
clean_backtrace.grep FrameworkRegexp
|
2007-01-22 14:43:50 +01:00
|
|
|
end
|
2007-02-09 09:04:31 +01:00
|
|
|
end
|