better_errors 0.0.2 → 0.3.0
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 +3 -0
- data/.yardopts +1 -0
- data/CONTRIBUTING.md +9 -0
- data/README.md +32 -8
- data/better_errors.gemspec +11 -5
- data/lib/better_errors/code_formatter.rb +61 -0
- data/lib/better_errors/core_ext/exception.rb +14 -13
- data/lib/better_errors/disable_logging_middleware.rb +16 -0
- data/lib/better_errors/error_page.rb +72 -48
- data/lib/better_errors/middleware.rb +77 -2
- data/lib/better_errors/rails.rb +7 -4
- data/lib/better_errors/repl/basic.rb +20 -0
- data/lib/better_errors/repl/pry.rb +77 -0
- data/lib/better_errors/repl.rb +30 -0
- data/lib/better_errors/stack_frame.rb +121 -0
- data/lib/better_errors/templates/main.erb +923 -0
- data/lib/better_errors/templates/variable_info.erb +69 -0
- data/lib/better_errors/version.rb +1 -1
- data/lib/better_errors.rb +99 -11
- data/spec/better_errors/code_formatter_spec.rb +51 -0
- data/spec/better_errors/error_page_spec.rb +33 -18
- data/spec/better_errors/middleware_spec.rb +29 -1
- data/spec/better_errors/repl/basic_spec.rb +32 -0
- data/spec/better_errors/stack_frame_spec.rb +121 -0
- data/spec/better_errors_spec.rb +13 -0
- data/spec/spec_helper.rb +3 -0
- metadata +92 -12
- data/lib/better_errors/error_frame.rb +0 -86
- data/lib/better_errors/error_page.erb +0 -234
- data/spec/better_errors/error_frame_spec.rb +0 -61
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: better_errors
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-12-
|
|
12
|
+
date: 2012-12-16 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rake
|
|
@@ -28,14 +28,30 @@ dependencies:
|
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
29
|
version: '0'
|
|
30
30
|
- !ruby/object:Gem::Dependency
|
|
31
|
-
name:
|
|
31
|
+
name: rspec
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
none: false
|
|
34
|
+
requirements:
|
|
35
|
+
- - ~>
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: 2.12.0
|
|
38
|
+
type: :development
|
|
39
|
+
prerelease: false
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ~>
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: 2.12.0
|
|
46
|
+
- !ruby/object:Gem::Dependency
|
|
47
|
+
name: binding_of_caller
|
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
|
33
49
|
none: false
|
|
34
50
|
requirements:
|
|
35
51
|
- - ! '>='
|
|
36
52
|
- !ruby/object:Gem::Version
|
|
37
53
|
version: '0'
|
|
38
|
-
type: :
|
|
54
|
+
type: :development
|
|
39
55
|
prerelease: false
|
|
40
56
|
version_requirements: !ruby/object:Gem::Requirement
|
|
41
57
|
none: false
|
|
@@ -44,14 +60,30 @@ dependencies:
|
|
|
44
60
|
- !ruby/object:Gem::Version
|
|
45
61
|
version: '0'
|
|
46
62
|
- !ruby/object:Gem::Dependency
|
|
47
|
-
name:
|
|
63
|
+
name: simplecov
|
|
48
64
|
requirement: !ruby/object:Gem::Requirement
|
|
49
65
|
none: false
|
|
50
66
|
requirements:
|
|
51
67
|
- - ! '>='
|
|
52
68
|
- !ruby/object:Gem::Version
|
|
53
69
|
version: '0'
|
|
54
|
-
type: :
|
|
70
|
+
type: :development
|
|
71
|
+
prerelease: false
|
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
73
|
+
none: false
|
|
74
|
+
requirements:
|
|
75
|
+
- - ! '>='
|
|
76
|
+
- !ruby/object:Gem::Version
|
|
77
|
+
version: '0'
|
|
78
|
+
- !ruby/object:Gem::Dependency
|
|
79
|
+
name: yard
|
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
|
81
|
+
none: false
|
|
82
|
+
requirements:
|
|
83
|
+
- - ! '>='
|
|
84
|
+
- !ruby/object:Gem::Version
|
|
85
|
+
version: '0'
|
|
86
|
+
type: :development
|
|
55
87
|
prerelease: false
|
|
56
88
|
version_requirements: !ruby/object:Gem::Requirement
|
|
57
89
|
none: false
|
|
@@ -59,7 +91,41 @@ dependencies:
|
|
|
59
91
|
- - ! '>='
|
|
60
92
|
- !ruby/object:Gem::Version
|
|
61
93
|
version: '0'
|
|
62
|
-
|
|
94
|
+
- !ruby/object:Gem::Dependency
|
|
95
|
+
name: erubis
|
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
|
97
|
+
none: false
|
|
98
|
+
requirements:
|
|
99
|
+
- - ! '>='
|
|
100
|
+
- !ruby/object:Gem::Version
|
|
101
|
+
version: 2.7.0
|
|
102
|
+
type: :runtime
|
|
103
|
+
prerelease: false
|
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
105
|
+
none: false
|
|
106
|
+
requirements:
|
|
107
|
+
- - ! '>='
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: 2.7.0
|
|
110
|
+
- !ruby/object:Gem::Dependency
|
|
111
|
+
name: coderay
|
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
|
113
|
+
none: false
|
|
114
|
+
requirements:
|
|
115
|
+
- - ! '>='
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: 1.0.0
|
|
118
|
+
type: :runtime
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
none: false
|
|
122
|
+
requirements:
|
|
123
|
+
- - ! '>='
|
|
124
|
+
- !ruby/object:Gem::Version
|
|
125
|
+
version: 1.0.0
|
|
126
|
+
description: Provides a better error page for Rails and other Rack apps. Includes
|
|
127
|
+
source code inspection, a live REPL and local/instance variable inspection for all
|
|
128
|
+
stack frames.
|
|
63
129
|
email:
|
|
64
130
|
- charlie@charliesomerville.com
|
|
65
131
|
executables: []
|
|
@@ -67,23 +133,34 @@ extensions: []
|
|
|
67
133
|
extra_rdoc_files: []
|
|
68
134
|
files:
|
|
69
135
|
- .gitignore
|
|
136
|
+
- .yardopts
|
|
137
|
+
- CONTRIBUTING.md
|
|
70
138
|
- Gemfile
|
|
71
139
|
- LICENSE.txt
|
|
72
140
|
- README.md
|
|
73
141
|
- Rakefile
|
|
74
142
|
- better_errors.gemspec
|
|
75
143
|
- lib/better_errors.rb
|
|
144
|
+
- lib/better_errors/code_formatter.rb
|
|
76
145
|
- lib/better_errors/core_ext/exception.rb
|
|
77
|
-
- lib/better_errors/
|
|
78
|
-
- lib/better_errors/error_page.erb
|
|
146
|
+
- lib/better_errors/disable_logging_middleware.rb
|
|
79
147
|
- lib/better_errors/error_page.rb
|
|
80
148
|
- lib/better_errors/middleware.rb
|
|
81
149
|
- lib/better_errors/rails.rb
|
|
150
|
+
- lib/better_errors/repl.rb
|
|
151
|
+
- lib/better_errors/repl/basic.rb
|
|
152
|
+
- lib/better_errors/repl/pry.rb
|
|
153
|
+
- lib/better_errors/stack_frame.rb
|
|
154
|
+
- lib/better_errors/templates/main.erb
|
|
155
|
+
- lib/better_errors/templates/variable_info.erb
|
|
82
156
|
- lib/better_errors/version.rb
|
|
83
|
-
- spec/better_errors/
|
|
157
|
+
- spec/better_errors/code_formatter_spec.rb
|
|
84
158
|
- spec/better_errors/error_page_spec.rb
|
|
85
159
|
- spec/better_errors/middleware_spec.rb
|
|
160
|
+
- spec/better_errors/repl/basic_spec.rb
|
|
161
|
+
- spec/better_errors/stack_frame_spec.rb
|
|
86
162
|
- spec/better_errors/support/my_source.rb
|
|
163
|
+
- spec/better_errors_spec.rb
|
|
87
164
|
- spec/spec_helper.rb
|
|
88
165
|
homepage: https://github.com/charliesome/better_errors
|
|
89
166
|
licenses:
|
|
@@ -109,11 +186,14 @@ rubyforge_project:
|
|
|
109
186
|
rubygems_version: 1.8.24
|
|
110
187
|
signing_key:
|
|
111
188
|
specification_version: 3
|
|
112
|
-
summary: Better
|
|
189
|
+
summary: Better error page for Rails and other Rack apps
|
|
113
190
|
test_files:
|
|
114
|
-
- spec/better_errors/
|
|
191
|
+
- spec/better_errors/code_formatter_spec.rb
|
|
115
192
|
- spec/better_errors/error_page_spec.rb
|
|
116
193
|
- spec/better_errors/middleware_spec.rb
|
|
194
|
+
- spec/better_errors/repl/basic_spec.rb
|
|
195
|
+
- spec/better_errors/stack_frame_spec.rb
|
|
117
196
|
- spec/better_errors/support/my_source.rb
|
|
197
|
+
- spec/better_errors_spec.rb
|
|
118
198
|
- spec/spec_helper.rb
|
|
119
199
|
has_rdoc:
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
module BetterErrors
|
|
2
|
-
class ErrorFrame
|
|
3
|
-
def self.from_exception(exception)
|
|
4
|
-
exception.backtrace.each_with_index.map { |frame, idx|
|
|
5
|
-
next unless frame =~ /\A(.*):(\d*):in `(.*)'\z/
|
|
6
|
-
b = exception.__better_errors_bindings_stack[idx]
|
|
7
|
-
ErrorFrame.new($1, $2.to_i, $3, b)
|
|
8
|
-
}.compact
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
attr_reader :filename, :line, :name, :frame_binding
|
|
12
|
-
|
|
13
|
-
def initialize(filename, line, name, frame_binding = nil)
|
|
14
|
-
@filename = filename
|
|
15
|
-
@line = line
|
|
16
|
-
@name = name
|
|
17
|
-
@frame_binding = frame_binding
|
|
18
|
-
|
|
19
|
-
set_pretty_method_name if frame_binding
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def application?
|
|
23
|
-
starts_with? filename, BetterErrors.application_root if BetterErrors.application_root
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def application_path
|
|
27
|
-
filename[(BetterErrors.application_root.length+1)..-1]
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def gem?
|
|
31
|
-
Gem.path.any? { |path| starts_with? filename, path }
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def gem_path
|
|
35
|
-
Gem.path.each do |path|
|
|
36
|
-
if starts_with? filename, path
|
|
37
|
-
return filename.gsub("#{path}/gems/", "(gem) ")
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def context
|
|
43
|
-
if application?
|
|
44
|
-
:application
|
|
45
|
-
elsif gem?
|
|
46
|
-
:gem
|
|
47
|
-
else
|
|
48
|
-
:dunno
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def pretty_path
|
|
53
|
-
case context
|
|
54
|
-
when :application; application_path
|
|
55
|
-
when :gem; gem_path
|
|
56
|
-
else filename
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def local_variables
|
|
61
|
-
return {} unless frame_binding
|
|
62
|
-
Hash[frame_binding.eval("local_variables").map { |x| [x, frame_binding.eval(x.to_s)] }]
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def instance_variables
|
|
66
|
-
return {} unless frame_binding
|
|
67
|
-
Hash[frame_binding.eval("instance_variables").map { |x| [x, frame_binding.eval(x.to_s)] }]
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
private
|
|
71
|
-
def set_pretty_method_name
|
|
72
|
-
name =~ /\A(block (\([^)]+\) )?in )?/
|
|
73
|
-
recv = frame_binding.eval("self")
|
|
74
|
-
method = frame_binding.eval("__method__")
|
|
75
|
-
@name = if recv.is_a? Module
|
|
76
|
-
"#{$1}#{recv}.#{method}"
|
|
77
|
-
else
|
|
78
|
-
"#{$1}#{recv.class}##{method}"
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def starts_with?(haystack, needle)
|
|
83
|
-
haystack[0, needle.length] == needle
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
end
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<title><%= exception.class %> at <%= request_path %></title>
|
|
5
|
-
<style>
|
|
6
|
-
* {
|
|
7
|
-
margin:0;
|
|
8
|
-
padding:0;
|
|
9
|
-
}
|
|
10
|
-
body {
|
|
11
|
-
font-family:Verdana, sans-serif;
|
|
12
|
-
margin:0;
|
|
13
|
-
font-size:13px;
|
|
14
|
-
}
|
|
15
|
-
header {
|
|
16
|
-
padding:32px 32px;
|
|
17
|
-
border-bottom:1px solid #ea6756;
|
|
18
|
-
background-color: #ffe5e7;
|
|
19
|
-
background-image: -webkit-gradient(linear, left top, left bottom, from(#ffe5e7), to(#ffb2b8)); /* Safari 4+, Chrome */
|
|
20
|
-
background-image: -webkit-linear-gradient(top, #ffe5e7, #ffb2b8); /* Chrome 10+, Safari 5.1+, iOS 5+ */
|
|
21
|
-
background-image: -moz-linear-gradient(top, #ffe5e7, #ffb2b8); /* Firefox 3.6-15 */
|
|
22
|
-
background-image: -o-linear-gradient(top, #ffe5e7, #ffb2b8); /* Opera 11.10-12.00 */
|
|
23
|
-
background-image: linear-gradient(to bottom, #ffe5e7, #ffb2b8); /* Firefox 16+, IE10, Opera 12.50+ */
|
|
24
|
-
}
|
|
25
|
-
h2 {
|
|
26
|
-
font-weight:normal;
|
|
27
|
-
margin:0;
|
|
28
|
-
margin-bottom:16px;
|
|
29
|
-
}
|
|
30
|
-
h2 span {
|
|
31
|
-
color:#666666;
|
|
32
|
-
}
|
|
33
|
-
header table {
|
|
34
|
-
border-collapse:collapse;
|
|
35
|
-
}
|
|
36
|
-
header table th {
|
|
37
|
-
text-align:right;
|
|
38
|
-
font-weight:bold;
|
|
39
|
-
padding-right:12px;
|
|
40
|
-
}
|
|
41
|
-
header table th, header table td {
|
|
42
|
-
padding:4px 6px;
|
|
43
|
-
}
|
|
44
|
-
.frames {
|
|
45
|
-
width:50%;
|
|
46
|
-
float:left;
|
|
47
|
-
}
|
|
48
|
-
.frames li {
|
|
49
|
-
list-style:none;
|
|
50
|
-
display:block;
|
|
51
|
-
padding:12px;
|
|
52
|
-
overflow:hidden;
|
|
53
|
-
cursor:pointer;
|
|
54
|
-
background-color: #f4f7ff;
|
|
55
|
-
background-image: -webkit-gradient(linear, left top, left bottom, from(#f4f7ff), to(#e4ebfe)); /* Safari 4+, Chrome */
|
|
56
|
-
background-image: -webkit-linear-gradient(top, #f4f7ff, #e4ebfe); /* Chrome 10+, Safari 5.1+, iOS 5+ */
|
|
57
|
-
background-image: -moz-linear-gradient(top, #f4f7ff, #e4ebfe); /* Firefox 3.6-15 */
|
|
58
|
-
background-image: -o-linear-gradient(top, #f4f7ff, #e4ebfe); /* Opera 11.10-12.00 */
|
|
59
|
-
background-image: linear-gradient(to bottom, #f4f7ff, #e4ebfe); /* Firefox 16+, IE10, Opera 12.50+ */
|
|
60
|
-
border-bottom:1px solid #cccccc;
|
|
61
|
-
}
|
|
62
|
-
.frames li:hover, .frames li.selected {
|
|
63
|
-
background-color: #e4ebfe;
|
|
64
|
-
background-image: -webkit-gradient(linear, left top, left bottom, from(#e4ebfe), to(#c2d3fe)); /* Safari 4+, Chrome */
|
|
65
|
-
background-image: -webkit-linear-gradient(top, #e4ebfe, #c2d3fe); /* Chrome 10+, Safari 5.1+, iOS 5+ */
|
|
66
|
-
background-image: -moz-linear-gradient(top, #e4ebfe, #c2d3fe); /* Firefox 3.6-15 */
|
|
67
|
-
background-image: -o-linear-gradient(top, #e4ebfe, #c2d3fe); /* Opera 11.10-12.00 */
|
|
68
|
-
background-image: linear-gradient(to bottom, #e4ebfe, #c2d3fe); /* Firefox 16+, IE10, Opera 12.50+ */
|
|
69
|
-
}
|
|
70
|
-
.frames .name, .frame_info h2.name {
|
|
71
|
-
font-family:Monaco, Incosolata, Consolas, monospace;
|
|
72
|
-
font-size:14px;
|
|
73
|
-
margin-bottom:4px;
|
|
74
|
-
}
|
|
75
|
-
.location {
|
|
76
|
-
color:#888888;
|
|
77
|
-
}
|
|
78
|
-
.location .filename, .location .line {
|
|
79
|
-
color:#333333;
|
|
80
|
-
}
|
|
81
|
-
.frame_info {
|
|
82
|
-
background-color:#efefef;
|
|
83
|
-
border-bottom:1px solid #cccccc;
|
|
84
|
-
float:left;
|
|
85
|
-
width:50%;
|
|
86
|
-
}
|
|
87
|
-
.frame_info > * {
|
|
88
|
-
margin:16px;
|
|
89
|
-
}
|
|
90
|
-
.frame_info h2 {
|
|
91
|
-
font-family:Monaco, Incosolata, Consolas, monospace;
|
|
92
|
-
}
|
|
93
|
-
.frame_info .code {
|
|
94
|
-
font-family:Monaco, Incosolata, Consolas, monospace;
|
|
95
|
-
background-color:#ffffff;
|
|
96
|
-
border:1px solid #cccccc;
|
|
97
|
-
border-collapse:collapse;
|
|
98
|
-
overflow:auto;
|
|
99
|
-
}
|
|
100
|
-
.frame_info .code pre:nth-child(2n+1) {
|
|
101
|
-
background-color:#f9f9f9;
|
|
102
|
-
}
|
|
103
|
-
.frame_info .code pre:nth-child(2n) {
|
|
104
|
-
background-color:#f3f3f3;
|
|
105
|
-
}
|
|
106
|
-
.frame_info .code pre.highlight {
|
|
107
|
-
background-color:#ffeaaa;
|
|
108
|
-
}
|
|
109
|
-
.frame_info .code .line {
|
|
110
|
-
text-align:right;
|
|
111
|
-
padding-right:12px;
|
|
112
|
-
padding-left:0px;
|
|
113
|
-
}
|
|
114
|
-
code {
|
|
115
|
-
background-color:#f0f0f0;
|
|
116
|
-
padding:2px 4px;
|
|
117
|
-
border:1px solid #d0d0d0;
|
|
118
|
-
}
|
|
119
|
-
h3 {
|
|
120
|
-
font-weight:normal;
|
|
121
|
-
border-top:1px solid #cccccc;
|
|
122
|
-
padding-top:16px;
|
|
123
|
-
}
|
|
124
|
-
.var_table {
|
|
125
|
-
border-collapse:collapse;
|
|
126
|
-
}
|
|
127
|
-
.var_table td {
|
|
128
|
-
padding:8px;
|
|
129
|
-
}
|
|
130
|
-
.var_table td.name {
|
|
131
|
-
font-style:italic;
|
|
132
|
-
}
|
|
133
|
-
.var_table tr {
|
|
134
|
-
border-bottom:1px solid #cccccc;
|
|
135
|
-
}
|
|
136
|
-
</style>
|
|
137
|
-
</head>
|
|
138
|
-
<body>
|
|
139
|
-
<header>
|
|
140
|
-
<h2><%= exception.class %> <span>at <%= request_path %></span></h2>
|
|
141
|
-
<table>
|
|
142
|
-
<tr>
|
|
143
|
-
<th>Message</th>
|
|
144
|
-
<td><%= exception.message %></td>
|
|
145
|
-
</tr>
|
|
146
|
-
<% if backtrace_frames.any? %>
|
|
147
|
-
<tr>
|
|
148
|
-
<th>File</th>
|
|
149
|
-
<td><%= backtrace_frames.first.filename %></td>
|
|
150
|
-
</tr>
|
|
151
|
-
<tr>
|
|
152
|
-
<th>Line</th>
|
|
153
|
-
<td><%= backtrace_frames.first.line %></td>
|
|
154
|
-
</tr>
|
|
155
|
-
<% end %>
|
|
156
|
-
</table>
|
|
157
|
-
</header>
|
|
158
|
-
<section class="backtrace">
|
|
159
|
-
<ul class="frames">
|
|
160
|
-
<% backtrace_frames.each_with_index do |frame, index| %>
|
|
161
|
-
<li
|
|
162
|
-
data-context="<%= frame.context %>"
|
|
163
|
-
data-full-filename="<%= frame.filename %>"
|
|
164
|
-
data-filename="<%= frame.pretty_path %>"
|
|
165
|
-
data-line="<%= frame.line %>"
|
|
166
|
-
data-name="<%= frame.name %>"
|
|
167
|
-
data-index="<%= index %>"
|
|
168
|
-
>
|
|
169
|
-
<div class="name"><%= frame.name %></div>
|
|
170
|
-
<div class="location"><span class="filename"><%= frame.pretty_path %></span>, line <span class="line"><%= frame.line %></span></div>
|
|
171
|
-
</li>
|
|
172
|
-
<% end %>
|
|
173
|
-
</ul>
|
|
174
|
-
<% backtrace_frames.each_with_index do |frame, index| %>
|
|
175
|
-
<div class="frame_info" id="frame_info_<%= index %>" style="display:none;">
|
|
176
|
-
<h2 class="name"><%= frame.name %></h2>
|
|
177
|
-
<div class="location"><span class="filename"><%= frame.pretty_path %></span>, line <span class="line"><%= frame.line %></span></div>
|
|
178
|
-
<%== highlighted_code_block frame %>
|
|
179
|
-
|
|
180
|
-
<h3>Local Variables</h3>
|
|
181
|
-
<table class="var_table">
|
|
182
|
-
<% frame.local_variables.each do |name, value| %>
|
|
183
|
-
<tr><td class="name"><%= name %></td><td><pre><%= value.inspect %></pre></td></tr>
|
|
184
|
-
<% end %>
|
|
185
|
-
</table>
|
|
186
|
-
|
|
187
|
-
<h3>Instance Variables</h3>
|
|
188
|
-
<table class="var_table">
|
|
189
|
-
<% frame.instance_variables.each do |name, value| %>
|
|
190
|
-
<tr><td class="name"><%= name %></td><td><pre><%= value.inspect %></pre></td></tr>
|
|
191
|
-
<% end %>
|
|
192
|
-
</table>
|
|
193
|
-
</div>
|
|
194
|
-
<% end %>
|
|
195
|
-
<div style="clear:both"></div>
|
|
196
|
-
</section>
|
|
197
|
-
</body>
|
|
198
|
-
<script>
|
|
199
|
-
(function() {
|
|
200
|
-
var previous = null;
|
|
201
|
-
var previousFrameInfo = null;
|
|
202
|
-
var frames = document.querySelectorAll("ul.frames li");
|
|
203
|
-
|
|
204
|
-
var header = document.querySelector("header");
|
|
205
|
-
var headerHeight = header.offsetHeight;
|
|
206
|
-
|
|
207
|
-
function selectFrameInfo(index) {
|
|
208
|
-
var el = document.getElementById("frame_info_" + index);
|
|
209
|
-
|
|
210
|
-
if(previousFrameInfo) {
|
|
211
|
-
previousFrameInfo.style.display = "none";
|
|
212
|
-
}
|
|
213
|
-
previousFrameInfo = el;
|
|
214
|
-
previousFrameInfo.style.display = "block";
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
for(var i = 0; i < frames.length; i++) {
|
|
218
|
-
(function(el) {
|
|
219
|
-
el.onclick = function() {
|
|
220
|
-
if(previous) {
|
|
221
|
-
previous.className = "";
|
|
222
|
-
}
|
|
223
|
-
el.className = "selected";
|
|
224
|
-
previous = el;
|
|
225
|
-
|
|
226
|
-
selectFrameInfo(el.attributes["data-index"].value);
|
|
227
|
-
};
|
|
228
|
-
})(frames[i]);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
document.querySelector(".frames li:first-child").click();
|
|
232
|
-
})();
|
|
233
|
-
</script>
|
|
234
|
-
</html>
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
module BetterErrors
|
|
4
|
-
describe ErrorFrame do
|
|
5
|
-
context "#application?" do
|
|
6
|
-
it "should be true for application filenames" do
|
|
7
|
-
BetterErrors.stub!(:application_root).and_return("/abc/xyz")
|
|
8
|
-
frame = ErrorFrame.new("/abc/xyz/app/controllers/crap_controller.rb", 123, "index")
|
|
9
|
-
|
|
10
|
-
frame.application?.should be_true
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it "should be false for everything else" do
|
|
14
|
-
BetterErrors.stub!(:application_root).and_return("/abc/xyz")
|
|
15
|
-
frame = ErrorFrame.new("/abc/nope", 123, "foo")
|
|
16
|
-
|
|
17
|
-
frame.application?.should be_false
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it "should not care if no application_root is set" do
|
|
21
|
-
frame = ErrorFrame.new("/abc/xyz/app/controllers/crap_controller.rb", 123, "index")
|
|
22
|
-
|
|
23
|
-
frame.application?.should be_false
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
context "#gem?" do
|
|
28
|
-
it "should be true for gem filenames" do
|
|
29
|
-
Gem.stub!(:path).and_return(["/abc/xyz"])
|
|
30
|
-
frame = ErrorFrame.new("/abc/xyz/gems/whatever-1.2.3/lib/whatever.rb", 123, "foo")
|
|
31
|
-
|
|
32
|
-
frame.gem?.should be_true
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it "should be false for everything else" do
|
|
36
|
-
Gem.stub!(:path).and_return(["/abc/xyz"])
|
|
37
|
-
frame = ErrorFrame.new("/abc/nope", 123, "foo")
|
|
38
|
-
|
|
39
|
-
frame.gem?.should be_false
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
context "#application_path" do
|
|
44
|
-
it "should chop off the application root" do
|
|
45
|
-
BetterErrors.stub!(:application_root).and_return("/abc/xyz")
|
|
46
|
-
frame = ErrorFrame.new("/abc/xyz/app/controllers/crap_controller.rb", 123, "index")
|
|
47
|
-
|
|
48
|
-
frame.application_path.should == "app/controllers/crap_controller.rb"
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
context "#gem_path" do
|
|
53
|
-
it "should chop of the gem path and stick (gem) there" do
|
|
54
|
-
Gem.stub!(:path).and_return(["/abc/xyz"])
|
|
55
|
-
frame = ErrorFrame.new("/abc/xyz/gems/whatever-1.2.3/lib/whatever.rb", 123, "foo")
|
|
56
|
-
|
|
57
|
-
frame.gem_path.should == "(gem) whatever-1.2.3/lib/whatever.rb"
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|