From 63f28a90116574eb7d2fdcdc353633d616c03327 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 3 Apr 2013 23:14:24 -0700 Subject: [PATCH] Nicer error messages for new linux caps --- lib/vagrant/errors.rb | 8 +++++ .../cap/mount_virtualbox_shared_folder.rb | 3 +- .../linux/cap/shell_expand_guest_path.rb | 3 +- plugins/guests/linux/guest.rb | 30 ------------------- templates/locales/en.yml | 13 +++++++- 5 files changed, 22 insertions(+), 35 deletions(-) diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index b90d4277e..4c7c151ea 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -239,6 +239,14 @@ module Vagrant error_key(:guest_not_detected) end + class LinuxMountFailed < VagrantError + error_key(:linux_mount_failed) + end + + class LinuxShellExpandFailed < VagrantError + error_key(:linux_shell_expand_failed) + end + class LocalDataDirectoryNotAccessible < VagrantError error_key(:local_data_dir_not_accessible) end diff --git a/plugins/guests/linux/cap/mount_virtualbox_shared_folder.rb b/plugins/guests/linux/cap/mount_virtualbox_shared_folder.rb index 127a673ea..2b3fa026d 100644 --- a/plugins/guests/linux/cap/mount_virtualbox_shared_folder.rb +++ b/plugins/guests/linux/cap/mount_virtualbox_shared_folder.rb @@ -26,8 +26,7 @@ module VagrantPlugins break if success attempts += 1 - # TODO: Nicer exception - raise "Mount failed" + raise Vagrant::Errors::LinuxMountFailed, :command => mount_command sleep 2 end diff --git a/plugins/guests/linux/cap/shell_expand_guest_path.rb b/plugins/guests/linux/cap/shell_expand_guest_path.rb index 23ee6174f..983e366f0 100644 --- a/plugins/guests/linux/cap/shell_expand_guest_path.rb +++ b/plugins/guests/linux/cap/shell_expand_guest_path.rb @@ -14,8 +14,7 @@ module VagrantPlugins if !real_path # If no real guest path was detected, this is really strange # and we raise an exception because this is a bug. - # TODO: Nice exception - raise "No expanded guest path detected." + raise LinuxShellExpandFailed end # Chomp the string so that any trailing newlines are killed diff --git a/plugins/guests/linux/guest.rb b/plugins/guests/linux/guest.rb index bef17506f..0a9261277 100644 --- a/plugins/guests/linux/guest.rb +++ b/plugins/guests/linux/guest.rb @@ -8,41 +8,11 @@ module VagrantPlugins class Guest < Vagrant.plugin("2", :guest) include Vagrant::Util::Retryable - class LinuxError < Vagrant::Errors::VagrantError - error_namespace("vagrant.guest.linux") - end - - def initialize(*args) - super - - @logger = Log4r::Logger.new("vagrant::guest::linux") - end - def detect?(machine) # TODO: Linux detection false end - def distro_dispatch - @vm.communicate.tap do |comm| - if comm.test("cat /etc/debian_version") - return :debian if comm.test("cat /proc/version | grep 'Debian'") - return :ubuntu if comm.test("cat /proc/version | grep 'Ubuntu'") - end - - return :gentoo if comm.test("cat /etc/gentoo-release") - return :fedora if comm.test("grep 'Fedora release 1[678]' /etc/redhat-release") - return :redhat if comm.test("cat /etc/redhat-release") - return :suse if comm.test("cat /etc/SuSE-release") - return :pld if comm.test("cat /etc/pld-release") - return :arch if comm.test("cat /etc/arch-release") - return :solaris if comm.test("grep 'Solaris' /etc/release") - end - - # Can't detect the distro, assume vanilla linux - nil - end - def halt begin @vm.communicate.sudo("shutdown -h now") diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 9a70947e0..3c5f3034d 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -204,6 +204,18 @@ en: running Vagrant. Local data directory: %{local_data_path} + linux_mount_failed: |- + Failed to mount folders in Linux guest. This is usually beacuse + the "vboxsf" file system is not available. Please verify that + the guest additions are properly installed in the guest and + can work properly. The command attempted was: + + %{command} + linux_shell_expand_failed: |- + Vagrant failed to determine the shell expansion of the guest path + for one of your shared folders. This is an extremely rare error case + and most likely indicates an unusual configuration of the guest system. + Please report a bug with your Vagrantfile. machine_guest_not_ready: |- Guest-specific operations were attempted on a machine that is not ready for guest communication. This should not happen and a bug @@ -1066,7 +1078,6 @@ en: for one of your shared folders. This is an extremely rare error case and most likely indicates an unusual configuration of the guest system. Please report a bug with your Vagrantfile. - mount_fail: "Failed to mount shared folders. `vboxsf` was not available." mount_nfs_fail: |- Mounting NFS shared folders failed. This is most often caused by the NFS client software not being installed on the guest machine. Please verify