From be6665864dda38bb6f862c258382346e4ef4d33a Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 29 Aug 2014 11:40:50 -0700 Subject: [PATCH] communicators/ssh: nicer errors for SSH exceptions [GH-4367] --- lib/vagrant/errors.rb | 4 ++++ plugins/communicators/ssh/communicator.rb | 3 +++ templates/locales/en.yml | 9 +++++++++ 3 files changed, 16 insertions(+) diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index 55789b00d..c1d8d8fb0 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -428,6 +428,10 @@ module Vagrant error_key(:multi_vm_target_required) end + class NetSSHException < VagrantError + error_key(:net_ssh_exception) + end + class NetworkCollision < VagrantError error_key(:collides, "vagrant.actions.vm.host_only_network") end diff --git a/plugins/communicators/ssh/communicator.rb b/plugins/communicators/ssh/communicator.rb index 8c5595d53..14b5bc58a 100644 --- a/plugins/communicators/ssh/communicator.rb +++ b/plugins/communicators/ssh/communicator.rb @@ -390,6 +390,9 @@ module VagrantPlugins rescue Errno::EHOSTUNREACH # This is raised if we can't work out how to route traffic. raise Vagrant::Errors::SSHNoRoute + rescue Net::SSH::Exception => e + # This is an internal error in Net::SSH + raise Vagrant::Errors::NetSSHException, message: e.message rescue NotImplementedError # This is raised if a private key type that Net-SSH doesn't support # is used. Show a nicer error. diff --git a/templates/locales/en.yml b/templates/locales/en.yml index a90860849..94a801337 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -799,6 +799,15 @@ en: the proper location. multi_vm_target_required: |- This command requires a specific VM name to target in a multi-VM environment. + net_ssh_exception: |- + An error occurred in the underlying SSH library that Vagrant uses. + The error message is shown below. In many cases, errors from this + library are caused by ssh-agent issues. Try disabling your SSH + agent or removing some keys and try again. + + If the problem persists, please report a bug to the net-ssh project. + + %{message} nfs_bad_exports: |- NFS is reporting that your exports file is invalid. Vagrant does this check before making any changes to the file. Please correct