Exception: Exception
- Defined in:
- lib/monetra/active_support/dependencies.rb,
lib/monetra/active_support/core_ext/exception.rb
Overview
Constant Summary
collapse
- TraceSubstitutions =
[]
- FrameworkRegexp =
/generated|vendor|dispatch|ruby|script\/\w+/
Instance Method Summary
collapse
Instance Method Details
#application_backtrace ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/monetra/active_support/core_ext/exception.rb', line 17
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
before_application_frame ? [] : trace
end
|
#blame_file!(file) ⇒ Object
170
171
172
|
# File 'lib/monetra/active_support/dependencies.rb', line 170
def blame_file!(file)
(@blamed_files ||= []).unshift file
end
|
#blamed_files ⇒ Object
174
175
176
|
# File 'lib/monetra/active_support/dependencies.rb', line 174
def blamed_files
@blamed_files ||= []
end
|
#clean_backtrace ⇒ Object
9
10
11
12
13
14
15
|
# File 'lib/monetra/active_support/core_ext/exception.rb', line 9
def clean_backtrace
backtrace.collect do |line|
Pathname.clean_within(TraceSubstitutions.inject(line) do |line, (regexp, sub)|
line.gsub regexp, sub
end)
end
end
|
#clean_message ⇒ Object
2
3
4
|
# File 'lib/monetra/active_support/core_ext/exception.rb', line 2
def clean_message
Pathname.clean_within message
end
|
#copy_blame!(exc) ⇒ Object
183
184
185
186
|
# File 'lib/monetra/active_support/dependencies.rb', line 183
def copy_blame!(exc)
@blamed_files = exc.blamed_files.clone
self
end
|
#describe_blame ⇒ Object
178
179
180
181
|
# File 'lib/monetra/active_support/dependencies.rb', line 178
def describe_blame
return nil if blamed_files.empty?
"This error occurred while loading the following files:\n #{blamed_files.join "\n "}"
end
|
#framework_backtrace ⇒ Object
30
31
32
|
# File 'lib/monetra/active_support/core_ext/exception.rb', line 30
def framework_backtrace
clean_backtrace.select {|line| line =~ FrameworkRegexp}
end
|