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
|
# 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 rescue_action_locally(request, exception)
template = ActionView::Base.new([RESCUES_TEMPLATE_PATH],
:request => request,
:exception => exception,
:application_trace => application_trace(exception),
:framework_trace => framework_trace(exception),
:full_trace => full_trace(exception)
)
file = "rescues/#{@@rescue_templates[exception.class.name]}.erb"
body = template.render(:file => file, :layout => 'rescues/layout.erb')
body = link_to_code(body)
render(status_code(exception), body)
end
end
end
|