Froze rails gems
[depot.git] / vendor / rails / activesupport / lib / active_support / core_ext / exception.rb
1 module ActiveSupport
2 if RUBY_VERSION >= '1.9'
3 FrozenObjectError = RuntimeError
4 else
5 FrozenObjectError = TypeError
6 end
7 end
8
9 class Exception # :nodoc:
10 def clean_message
11 Pathname.clean_within message
12 end
13
14 TraceSubstitutions = []
15 FrameworkRegexp = /generated|vendor|dispatch|ruby|script\/\w+/
16
17 def clean_backtrace
18 backtrace.collect do |line|
19 Pathname.clean_within(TraceSubstitutions.inject(line) do |result, (regexp, sub)|
20 result.gsub regexp, sub
21 end)
22 end
23 end
24
25 def application_backtrace
26 before_application_frame = true
27
28 trace = clean_backtrace.reject do |line|
29 non_app_frame = (line =~ FrameworkRegexp)
30 before_application_frame = false unless non_app_frame
31 non_app_frame && ! before_application_frame
32 end
33
34 # If we didn't find any application frames, return an empty app trace.
35 before_application_frame ? [] : trace
36 end
37
38 def framework_backtrace
39 clean_backtrace.grep FrameworkRegexp
40 end
41 end