better_errors 0.0.1 → 0.0.2
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.
Potentially problematic release.
This version of better_errors might be problematic. Click here for more details.
- data/README.md +8 -2
- data/lib/better_errors/error_frame.rb +16 -2
- data/lib/better_errors/error_page.erb +0 -10
- data/lib/better_errors/error_page.rb +4 -6
- data/lib/better_errors/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -2,11 +2,17 @@
|
|
2
2
|
|
3
3
|
Better Errors replaces the standard Rails error page with a much better and more useful error page. It is also usable outside of Rails.
|
4
4
|
|
5
|
-

|
6
|
+
|
7
|
+
## Features
|
8
|
+
|
9
|
+
* Full stack trace
|
10
|
+
* Source code inspection for all stack frames (with highlighting)
|
11
|
+
* Local and instance variable inspection
|
6
12
|
|
7
13
|
## Installation
|
8
14
|
|
9
|
-
Add this line to your application's Gemfile:
|
15
|
+
Add this line to your application's Gemfile (under the **development** group):
|
10
16
|
|
11
17
|
gem 'better_errors'
|
12
18
|
|
@@ -3,17 +3,20 @@ module BetterErrors
|
|
3
3
|
def self.from_exception(exception)
|
4
4
|
exception.backtrace.each_with_index.map { |frame, idx|
|
5
5
|
next unless frame =~ /\A(.*):(\d*):in `(.*)'\z/
|
6
|
-
|
6
|
+
b = exception.__better_errors_bindings_stack[idx]
|
7
|
+
ErrorFrame.new($1, $2.to_i, $3, b)
|
7
8
|
}.compact
|
8
9
|
end
|
9
10
|
|
10
11
|
attr_reader :filename, :line, :name, :frame_binding
|
11
12
|
|
12
|
-
def initialize(filename, line, name, frame_binding)
|
13
|
+
def initialize(filename, line, name, frame_binding = nil)
|
13
14
|
@filename = filename
|
14
15
|
@line = line
|
15
16
|
@name = name
|
16
17
|
@frame_binding = frame_binding
|
18
|
+
|
19
|
+
set_pretty_method_name if frame_binding
|
17
20
|
end
|
18
21
|
|
19
22
|
def application?
|
@@ -65,6 +68,17 @@ module BetterErrors
|
|
65
68
|
end
|
66
69
|
|
67
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
|
+
|
68
82
|
def starts_with?(haystack, needle)
|
69
83
|
haystack[0, needle.length] == needle
|
70
84
|
end
|
@@ -214,15 +214,6 @@
|
|
214
214
|
previousFrameInfo.style.display = "block";
|
215
215
|
}
|
216
216
|
|
217
|
-
function updateMarginTop() {
|
218
|
-
return;
|
219
|
-
if(previousFrameInfo) {
|
220
|
-
previousFrameInfo.style.marginTop = Math.max(window.scrollY - headerHeight, 0) + "px";
|
221
|
-
}
|
222
|
-
}
|
223
|
-
|
224
|
-
window.onscroll = updateMarginTop;
|
225
|
-
|
226
217
|
for(var i = 0; i < frames.length; i++) {
|
227
218
|
(function(el) {
|
228
219
|
el.onclick = function() {
|
@@ -233,7 +224,6 @@
|
|
233
224
|
previous = el;
|
234
225
|
|
235
226
|
selectFrameInfo(el.attributes["data-index"].value);
|
236
|
-
updateMarginTop();
|
237
227
|
};
|
238
228
|
})(frames[i]);
|
239
229
|
}
|
@@ -23,12 +23,10 @@ module BetterErrors
|
|
23
23
|
|
24
24
|
private
|
25
25
|
def real_exception(exception)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
return exception
|
31
|
-
end
|
26
|
+
if exception.respond_to? :original_exception
|
27
|
+
exception.original_exception
|
28
|
+
else
|
29
|
+
exception
|
32
30
|
end
|
33
31
|
end
|
34
32
|
|