Make plugin loading more robust to errors
This commit is contained in:
parent
1162c2dbfc
commit
3df6088db0
|
@ -172,6 +172,17 @@ module Vagrant
|
|||
require name
|
||||
rescue LoadError
|
||||
raise Errors::PluginLoadError, :plugin => name
|
||||
rescue Exception => e
|
||||
# Since this is a rare case, we create a one-time logger here
|
||||
# in order to output the error
|
||||
logger = Log4r::Logger.new("vagrant::root")
|
||||
logger.error("Failed to load plugin: #{name}")
|
||||
logger.error(" -- Error: #{e.inspect}")
|
||||
logger.error(" -- Backtrace:")
|
||||
logger.error(e.backtrace.join("\n"))
|
||||
|
||||
# And raise an error itself
|
||||
raise Errors::PluginLoadFailed, :plugin => name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -610,7 +610,11 @@ module Vagrant
|
|||
data = JSON.parse(plugins_json_file.read)
|
||||
data["installed"].each do |plugin|
|
||||
@logger.info("Loading plugin from JSON: #{plugin}")
|
||||
begin
|
||||
Vagrant.require_plugin(plugin)
|
||||
rescue Errors::PluginLoadFailed => e
|
||||
@ui.error(e.message)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -349,6 +349,10 @@ module Vagrant
|
|||
error_key(:plugin_load_error)
|
||||
end
|
||||
|
||||
class PluginLoadFailed < VagrantError
|
||||
error_key(:plugin_load_failed)
|
||||
end
|
||||
|
||||
class SCPPermissionDenied < VagrantError
|
||||
status_code(82)
|
||||
error_key(:scp_permission_denied)
|
||||
|
|
|
@ -178,6 +178,8 @@ en:
|
|||
plugin_load_error: |-
|
||||
The plugin "%{plugin}" could not be found. Please make sure that it is
|
||||
properly installed via `vagrant plugin`.
|
||||
plugin_load_failed: |-
|
||||
Failed to load the "%{plugin}" plugin. View logs for more details.
|
||||
port_collision_resume: |-
|
||||
This VM cannot be resumed, because the forwarded ports would collide with
|
||||
another running virtual machine. Normally, Vagrant will attempt to fix this
|
||||
|
|
Loading…
Reference in New Issue