mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 15:35:27 +08:00
DEV: Apply syntax_tree formatting to lib/*
This commit is contained in:
@ -5,25 +5,37 @@ module Plugin
|
||||
begin
|
||||
block.call
|
||||
rescue => error
|
||||
plugins_directory = Rails.root + 'plugins'
|
||||
plugins_directory = Rails.root + "plugins"
|
||||
|
||||
if error.backtrace && error.backtrace_locations
|
||||
plugin_path = error.backtrace_locations.lazy.map do |location|
|
||||
Pathname.new(location.absolute_path)
|
||||
.ascend
|
||||
plugin_path =
|
||||
error
|
||||
.backtrace_locations
|
||||
.lazy
|
||||
.find { |path| path.parent == plugins_directory }
|
||||
end.next
|
||||
.map do |location|
|
||||
Pathname
|
||||
.new(location.absolute_path)
|
||||
.ascend
|
||||
.lazy
|
||||
.find { |path| path.parent == plugins_directory }
|
||||
end
|
||||
.next
|
||||
|
||||
raise unless plugin_path
|
||||
|
||||
stack_trace = error.backtrace.each_with_index.inject([]) do |messages, (line, index)|
|
||||
if index == 0
|
||||
messages << "#{line}: #{error} (#{error.class})"
|
||||
else
|
||||
messages << "\t#{index}: from #{line}"
|
||||
end
|
||||
end.reverse.join("\n")
|
||||
stack_trace =
|
||||
error
|
||||
.backtrace
|
||||
.each_with_index
|
||||
.inject([]) do |messages, (line, index)|
|
||||
if index == 0
|
||||
messages << "#{line}: #{error} (#{error.class})"
|
||||
else
|
||||
messages << "\t#{index}: from #{line}"
|
||||
end
|
||||
end
|
||||
.reverse
|
||||
.join("\n")
|
||||
|
||||
STDERR.puts <<~TEXT
|
||||
#{stack_trace}
|
||||
|
Reference in New Issue
Block a user