better_errors 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of better_errors might be problematic. Click here for more details.

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
- ![image](http://i.imgur.com/1GepF.png)
5
+ ![image](http://i.imgur.com/O9anD.png)
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
- ErrorFrame.new($1, $2.to_i, $3, exception.__better_errors_bindings_stack[idx])
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
- loop do
27
- case exception
28
- when ActionView::Template::Error; exception = exception.original_exception
29
- else
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
 
@@ -1,3 +1,3 @@
1
1
  module BetterErrors
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: