4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/rubymine_heaven/linkable_errors.rb', line 4
def self.included(base)
base.class_eval do
private
def link_to_code(text)
String.new(text).gsub(/(\/?[\w\/\.@-]+)\:(\d+)/) do |match|
file = $1 || "file??"
line = $2 || "line-no??"
file = Rails.root + file if file =~ Rails::BacktraceCleaner::APP_DIRS_PATTERN
"<a href='x-mine://open?file=#{file}&line=#{line}'>#{match}</a>"
end
end
def render_exception(env, exception)
begin
wrapper = ActionDispatch::ExceptionWrapper.new(env, exception)
log_error(env, wrapper)
if env['action_dispatch.show_detailed_exceptions']
template = ActionView::Base.new([RESCUES_TEMPLATE_PATH],
:request => ActionDispatch::Request.new(env),
:exception => wrapper.exception,
:application_trace => wrapper.application_trace,
:framework_trace => wrapper.framework_trace,
:full_trace => wrapper.full_trace
)
file = "rescues/#{wrapper.rescue_template}"
body = template.render(:template => file, :layout => 'rescues/layout')
body = link_to_code(body)
render(wrapper.status_code, body)
else
raise exception
end
rescue => e
p e
end
end
end
end
|