Update plugin loading to prevent error suppression
Only catch exception types we care about when attempting to load plugins. If no require call is successful, force an exception instead of ignoring.
This commit is contained in:
parent
1bba1f86bb
commit
d58096da31
|
@ -288,7 +288,7 @@ end
|
||||||
if Vagrant.plugins_init?
|
if Vagrant.plugins_init?
|
||||||
begin
|
begin
|
||||||
Vagrant::Bundler.instance.init!(plugins)
|
Vagrant::Bundler.instance.init!(plugins)
|
||||||
rescue Exception => e
|
rescue StandardError, ScriptError => e
|
||||||
global_logger.error("Plugin initialization error - #{e.class}: #{e}")
|
global_logger.error("Plugin initialization error - #{e.class}: #{e}")
|
||||||
e.backtrace.each do |backtrace_line|
|
e.backtrace.each do |backtrace_line|
|
||||||
global_logger.debug(backtrace_line)
|
global_logger.debug(backtrace_line)
|
||||||
|
@ -334,18 +334,16 @@ if Vagrant.plugins_enabled?
|
||||||
plugins.each do |plugin_name, plugin_info|
|
plugins.each do |plugin_name, plugin_info|
|
||||||
if plugin_info["require"].to_s.empty?
|
if plugin_info["require"].to_s.empty?
|
||||||
begin
|
begin
|
||||||
global_logger.debug("Loading plugin `#{plugin_name}` with default require: `#{plugin_name}`")
|
global_logger.info("Loading plugin `#{plugin_name}` with default require: `#{plugin_name}`")
|
||||||
require plugin_name
|
require plugin_name
|
||||||
rescue LoadError, Gem::LoadError => load_error
|
rescue LoadError => err
|
||||||
if plugin_name.include?("-")
|
if plugin_name.include?("-")
|
||||||
begin
|
plugin_slash = plugin_name.gsub("-", "/")
|
||||||
plugin_slash = plugin_name.gsub("-", "/")
|
global_logger.error("Failed to load plugin `#{plugin_name}` with default require. - #{err.class}: #{err}")
|
||||||
global_logger.debug("Failed to load plugin `#{plugin_name}` with default require.")
|
global_logger.info("Loading plugin `#{plugin_name}` with slash require: `#{plugin_slash}`")
|
||||||
global_logger.debug("Loading plugin `#{plugin_name}` with slash require: `#{plugin_slash}`")
|
require plugin_slash
|
||||||
require plugin_slash
|
else
|
||||||
rescue LoadError, Gem::LoadError
|
raise
|
||||||
global_logger.warn("Failed to load plugin `#{plugin_name}`. Assuming library and moving on.")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -358,12 +356,12 @@ if Vagrant.plugins_enabled?
|
||||||
global_logger.debug("Bundler detected in use. Loading `:plugins` group.")
|
global_logger.debug("Bundler detected in use. Loading `:plugins` group.")
|
||||||
::Bundler.require(:plugins)
|
::Bundler.require(:plugins)
|
||||||
end
|
end
|
||||||
rescue Exception => e
|
rescue ScriptError, StandardError => err
|
||||||
global_logger.error("Plugin loading error: #{e.class} - #{e}")
|
global_logger.error("Plugin loading error: #{err.class} - #{err}")
|
||||||
e.backtrace.each do |backtrace_line|
|
err.backtrace.each do |backtrace_line|
|
||||||
global_logger.debug(backtrace_line)
|
global_logger.debug(backtrace_line)
|
||||||
end
|
end
|
||||||
raise Vagrant::Errors::PluginLoadError, message: e.to_s
|
raise Vagrant::Errors::PluginLoadError, message: err.to_s
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
global_logger.debug("Plugin loading is currently disabled.")
|
global_logger.debug("Plugin loading is currently disabled.")
|
||||||
|
|
Loading…
Reference in New Issue