linkify_errors 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/lib/linkify_errors.rb +44 -0
- data/lib/linkify_errors/version.rb +3 -0
- data/lib/templates/rescues/_request_and_response.erb +31 -0
- data/lib/templates/rescues/_trace.erb +26 -0
- data/lib/templates/rescues/diagnostics.erb +10 -0
- data/lib/templates/rescues/layout.erb +31 -0
- data/lib/templates/rescues/missing_template.erb +2 -0
- data/lib/templates/rescues/routing_error.erb +10 -0
- data/lib/templates/rescues/template_error.erb +17 -0
- data/lib/templates/rescues/unknown_action.erb +2 -0
- data/linkify_errors.gemspec +21 -0
- metadata +80 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'action_dispatch/middleware/show_exceptions'
|
3
|
+
|
4
|
+
module ActionDispatch
|
5
|
+
class ShowExceptions
|
6
|
+
def rescue_action_locally(request, exception)
|
7
|
+
template = ActionView::Base.new([File.join(File.dirname(__FILE__), 'templates')],
|
8
|
+
:request => request,
|
9
|
+
:exception => exception,
|
10
|
+
:application_trace => application_trace(exception),
|
11
|
+
:framework_trace => framework_trace(exception),
|
12
|
+
:full_trace => full_trace(exception)
|
13
|
+
)
|
14
|
+
file = "rescues/#{@@rescue_templates[exception.class.name]}.erb"
|
15
|
+
body = template.render(:file => file, :layout => 'rescues/layout.erb')
|
16
|
+
render(status_code(exception), body)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
module LinkifyErrors
|
22
|
+
PROTOCOL = "editfile"
|
23
|
+
|
24
|
+
def self.linkify(str)
|
25
|
+
file, line, desc = str.split(':')
|
26
|
+
|
27
|
+
if file[0..0] == "/"
|
28
|
+
# we already have an absolute path. We're good!
|
29
|
+
elsif file =~ /(.*) \((.*)\) (.*)/
|
30
|
+
# This is a part-of-rails gem, e.g. "actionpack (3.1.0.beta1) lib/action_controller/....."
|
31
|
+
gemspecs = Gem.source_index.find_name($1)
|
32
|
+
version_in_use = gemspecs.find {|gemspec| gemspec.version.to_s == $2 }
|
33
|
+
base_path = version_in_use.rg_full_gem_path
|
34
|
+
file = "#{base_path}/#{$3}"
|
35
|
+
else
|
36
|
+
# This is an app-local file, and just needs to be joined to Rails.root
|
37
|
+
file = Rails.root + file
|
38
|
+
end
|
39
|
+
|
40
|
+
url = "#{PROTOCOL}://#{line}@#{file}"
|
41
|
+
|
42
|
+
"<a href='#{url}'>#{str}</a>".html_safe
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<% unless @exception.blamed_files.blank? %>
|
2
|
+
<% if (hide = @exception.blamed_files.length > 8) %>
|
3
|
+
<a href="#" onclick="document.getElementById('blame_trace').style.display='block'; return false;">Show blamed files</a>
|
4
|
+
<% end %>
|
5
|
+
<pre id="blame_trace" <%='style="display:none"' if hide %>><code><%=h @exception.describe_blame %></code></pre>
|
6
|
+
<% end %>
|
7
|
+
|
8
|
+
<%
|
9
|
+
clean_params = @request.filtered_parameters.clone
|
10
|
+
clean_params.delete("action")
|
11
|
+
clean_params.delete("controller")
|
12
|
+
|
13
|
+
request_dump = clean_params.empty? ? 'None' : clean_params.inspect.gsub(',', ",\n")
|
14
|
+
|
15
|
+
def debug_hash(hash)
|
16
|
+
hash.sort_by { |k, v| k.to_s }.map { |k, v| "#{k}: #{v.inspect rescue $!.message}" }.join("\n")
|
17
|
+
end unless self.class.method_defined?(:debug_hash)
|
18
|
+
%>
|
19
|
+
|
20
|
+
<h2 style="margin-top: 30px">Request</h2>
|
21
|
+
<p><b>Parameters</b>: <pre><%=h request_dump %></pre></p>
|
22
|
+
|
23
|
+
<p><a href="#" onclick="document.getElementById('session_dump').style.display='block'; return false;">Show session dump</a></p>
|
24
|
+
<div id="session_dump" style="display:none"><pre><%= debug_hash @request.session %></pre></div>
|
25
|
+
|
26
|
+
<p><a href="#" onclick="document.getElementById('env_dump').style.display='block'; return false;">Show env dump</a></p>
|
27
|
+
<div id="env_dump" style="display:none"><pre><%= debug_hash @request.env.slice(*@request.class::ENV_METHODS) %></pre></div>
|
28
|
+
|
29
|
+
|
30
|
+
<h2 style="margin-top: 30px">Response</h2>
|
31
|
+
<p><b>Headers</b>: <pre><%=h defined?(@response) ? @response.headers.inspect.gsub(',', ",\n") : 'None' %></pre></p>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<%
|
2
|
+
traces = [
|
3
|
+
["Application Trace", @application_trace],
|
4
|
+
["Framework Trace", @framework_trace],
|
5
|
+
["Full Trace", @full_trace]
|
6
|
+
]
|
7
|
+
names = traces.collect {|name, trace| name}
|
8
|
+
%>
|
9
|
+
|
10
|
+
<p><code>Rails.root: <%= defined?(Rails) && Rails.respond_to?(:root) ? Rails.root : "unset" %></code></p>
|
11
|
+
|
12
|
+
<div id="traces">
|
13
|
+
<% names.each do |name| %>
|
14
|
+
<%
|
15
|
+
show = "document.getElementById('#{name.gsub(/\s/, '-')}').style.display='block';"
|
16
|
+
hide = (names - [name]).collect {|hide_name| "document.getElementById('#{hide_name.gsub(/\s/, '-')}').style.display='none';"}
|
17
|
+
%>
|
18
|
+
<a href="#" onclick="<%= hide.join %><%= show %>; return false;"><%= name %></a> <%= '|' unless names.last == name %>
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
<% traces.each do |name, trace| %>
|
22
|
+
<div id="<%= name.gsub(/\s/, '-') %>" style="display: <%= (name == "Application Trace") ? 'block' : 'none' %>;">
|
23
|
+
<pre><code><%= trace.map{|t|LinkifyErrors.linkify(t).html_safe}.join("<br/>").html_safe %></code></pre>
|
24
|
+
</div>
|
25
|
+
<% end %>
|
26
|
+
</div>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<h1>
|
2
|
+
<%=h @exception.class.to_s %>
|
3
|
+
<% if @request.parameters['controller'] %>
|
4
|
+
in <%=h @request.parameters['controller'].camelize %>Controller<% if @request.parameters['action'] %>#<%=h @request.parameters['action'] %><% end %>
|
5
|
+
<% end %>
|
6
|
+
</h1>
|
7
|
+
<pre><%=h @exception.message %></pre>
|
8
|
+
|
9
|
+
<%= render :template => "rescues/_trace" %>
|
10
|
+
<%= render :template => "rescues/_request_and_response" %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8" />
|
5
|
+
<title>Action Controller: Exception caught</title>
|
6
|
+
<style>
|
7
|
+
body { background-color: #fff; color: #333; }
|
8
|
+
|
9
|
+
body, p, ol, ul, td {
|
10
|
+
font-family: helvetica, verdana, arial, sans-serif;
|
11
|
+
font-size: 13px;
|
12
|
+
line-height: 18px;
|
13
|
+
}
|
14
|
+
|
15
|
+
pre {
|
16
|
+
background-color: #eee;
|
17
|
+
padding: 10px;
|
18
|
+
font-size: 11px;
|
19
|
+
}
|
20
|
+
|
21
|
+
a { color: #000; }
|
22
|
+
a:visited { color: #666; }
|
23
|
+
a:hover { color: #fff; background-color:#000; }
|
24
|
+
</style>
|
25
|
+
</head>
|
26
|
+
<body>
|
27
|
+
|
28
|
+
<%= yield %>
|
29
|
+
|
30
|
+
</body>
|
31
|
+
</html>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<h1>Routing Error</h1>
|
2
|
+
<p><pre><%=h @exception.message %></pre></p>
|
3
|
+
<% unless @exception.failures.empty? %><p>
|
4
|
+
<h2>Failure reasons:</h2>
|
5
|
+
<ol>
|
6
|
+
<% @exception.failures.each do |route, reason| %>
|
7
|
+
<li><code><%=h route.inspect.gsub('\\', '') %></code> failed because <%=h reason.downcase %></li>
|
8
|
+
<% end %>
|
9
|
+
</ol>
|
10
|
+
</p><% end %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<h1>
|
2
|
+
<%=h @exception.original_exception.class.to_s %> in
|
3
|
+
<%=h @request.parameters["controller"].capitalize if @request.parameters["controller"]%>#<%=h @request.parameters["action"] %>
|
4
|
+
</h1>
|
5
|
+
|
6
|
+
<p>
|
7
|
+
Showing <i><%=h @exception.file_name %></i> where line <b>#<%=h @exception.line_number %></b> raised:
|
8
|
+
<pre><code><%=h @exception.message %></code></pre>
|
9
|
+
</p>
|
10
|
+
|
11
|
+
<p>Extracted source (around line <b>#<%=h @exception.line_number %></b>):
|
12
|
+
<pre><code><%=h @exception.source_extract %></code></pre></p>
|
13
|
+
|
14
|
+
<p><%=h @exception.sub_template_message %></p>
|
15
|
+
|
16
|
+
<%= render :template => "rescues/_trace" %>
|
17
|
+
<%= render :template => "rescues/_request_and_response" %>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "linkify_errors/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "linkify_errors"
|
7
|
+
s.version = LinkifyErrors::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Burke Libbey"]
|
10
|
+
s.email = ["burke@burkelibbey.org"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{does things.}
|
13
|
+
s.description = %q{does things and stuff.}
|
14
|
+
|
15
|
+
s.add_dependency 'actionpack'
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: linkify_errors
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Burke Libbey
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-05-18 00:00:00 -05:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: actionpack
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
description: does things and stuff.
|
28
|
+
email:
|
29
|
+
- burke@burkelibbey.org
|
30
|
+
executables: []
|
31
|
+
|
32
|
+
extensions: []
|
33
|
+
|
34
|
+
extra_rdoc_files: []
|
35
|
+
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- Rakefile
|
40
|
+
- lib/linkify_errors.rb
|
41
|
+
- lib/linkify_errors/version.rb
|
42
|
+
- lib/templates/rescues/_request_and_response.erb
|
43
|
+
- lib/templates/rescues/_trace.erb
|
44
|
+
- lib/templates/rescues/diagnostics.erb
|
45
|
+
- lib/templates/rescues/layout.erb
|
46
|
+
- lib/templates/rescues/missing_template.erb
|
47
|
+
- lib/templates/rescues/routing_error.erb
|
48
|
+
- lib/templates/rescues/template_error.erb
|
49
|
+
- lib/templates/rescues/unknown_action.erb
|
50
|
+
- linkify_errors.gemspec
|
51
|
+
has_rdoc: true
|
52
|
+
homepage: ""
|
53
|
+
licenses: []
|
54
|
+
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: "0"
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: "0"
|
72
|
+
requirements: []
|
73
|
+
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 1.6.2
|
76
|
+
signing_key:
|
77
|
+
specification_version: 3
|
78
|
+
summary: does things.
|
79
|
+
test_files: []
|
80
|
+
|