Skip to content

Commit d2686c2

Browse files
author
Charlie Somerville
committed
files under vendor/ should not be treated as application frames
1 parent 03a94c7 commit d2686c2

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

lib/better_errors/stack_frame.rb

+14-13
Original file line numberDiff line numberDiff line change
@@ -48,31 +48,32 @@ def self.syntax_error?(exception)
4848
def self.has_binding_stack?(exception)
4949
exception.respond_to?(:__better_errors_bindings_stack) && exception.__better_errors_bindings_stack.any?
5050
end
51-
51+
5252
attr_reader :filename, :line, :name, :frame_binding
53-
53+
5454
def initialize(filename, line, name, frame_binding = nil)
5555
@filename = filename
5656
@line = line
5757
@name = name
5858
@frame_binding = frame_binding
59-
59+
6060
set_pretty_method_name if frame_binding
6161
end
62-
62+
6363
def application?
64-
root = BetterErrors.application_root
65-
filename.index(root) == 0 if root
64+
if root = BetterErrors.application_root
65+
filename.index(root) == 0 && filename.index("#{root}/vendor") != 0
66+
end
6667
end
67-
68+
6869
def application_path
6970
filename[(BetterErrors.application_root.length+1)..-1]
7071
end
7172

7273
def gem?
7374
Gem.path.any? { |path| filename.index(path) == 0 }
7475
end
75-
76+
7677
def gem_path
7778
if path = Gem.path.detect { |path| filename.index(path) == 0 }
7879
gem_name_and_version, path = filename.sub("#{path}/gems/", "").split("/", 2)
@@ -88,7 +89,7 @@ def class_name
8889
def method_name
8990
@method_name || @name
9091
end
91-
92+
9293
def context
9394
if gem?
9495
:gem
@@ -98,15 +99,15 @@ def context
9899
:dunno
99100
end
100101
end
101-
102+
102103
def pretty_path
103104
case context
104105
when :application; application_path
105106
when :gem; gem_path
106107
else filename
107108
end
108109
end
109-
110+
110111
def local_variables
111112
return {} unless frame_binding
112113
frame_binding.eval("local_variables").each_with_object({}) do |name, hash|
@@ -122,7 +123,7 @@ def local_variables
122123
end
123124
end
124125
end
125-
126+
126127
def instance_variables
127128
return {} unless frame_binding
128129
Hash[visible_instance_variables.map { |x|
@@ -137,7 +138,7 @@ def visible_instance_variables
137138
def to_s
138139
"#{pretty_path}:#{line}:in `#{name}'"
139140
end
140-
141+
141142
private
142143
def set_pretty_method_name
143144
return if RUBY_VERSION < "2.0.0"

0 commit comments

Comments
 (0)