mirror of https://github.com/rails/rails
Merge pull request #50764 from eugeneius/syntax_error_proxy_nil_backtrace_locations
Handle nil backtrace_locations in SyntaxErrorProxy
This commit is contained in:
commit
0656787be6
|
@ -83,6 +83,14 @@ module ActionDispatch
|
|||
end
|
||||
end
|
||||
|
||||
test "#source_extracts works with nil backtrace_locations" do
|
||||
exception = begin eval "class Foo; yield; end"; rescue SyntaxError => ex; ex; end
|
||||
|
||||
wrapper = ExceptionWrapper.new(nil, exception)
|
||||
|
||||
assert_empty wrapper.source_extracts
|
||||
end
|
||||
|
||||
if defined?(ErrorHighlight) && Gem::Version.new(ErrorHighlight::VERSION) >= Gem::Version.new("0.4.0")
|
||||
test "#source_extracts works with error_highlight" do
|
||||
lineno = __LINE__
|
||||
|
|
|
@ -32,6 +32,8 @@ module ActiveSupport
|
|||
end
|
||||
|
||||
def backtrace_locations
|
||||
return nil if super.nil?
|
||||
|
||||
parse_message_for_trace.map { |trace|
|
||||
file, line = trace.match(/^(.+?):(\d+).*$/, &:captures) || trace
|
||||
BacktraceLocation.new(file, line.to_i, trace)
|
||||
|
|
Loading…
Reference in New Issue