Catch and handle customization errors

This commit is contained in:
Mitchell Hashimoto 2011-12-21 16:37:59 -08:00
parent e1d0ce19ce
commit a3395f94ab
4 changed files with 23 additions and 2 deletions

View File

@ -18,7 +18,13 @@ module Vagrant
arg
end
env[:vm].driver.execute_command(processed_command)
result = env[:vm].driver.execute_command(processed_command)
if result.exit_code != 0
raise Errors::VMCustomizationFailed, {
:command => processed_command.inspect,
:error => result.stderr
}
end
end
end

View File

@ -76,7 +76,7 @@ module Vagrant
# Executes a raw command.
def execute_command(command)
execute(*command)
raw(*command)
end
# Forwards a set of ports for a VM.

View File

@ -334,6 +334,11 @@ module Vagrant
error_key(:no_base_mac, "vagrant.actions.vm.match_mac")
end
class VMCustomizationFailed < VagrantError
status_code(61)
error_key(:failure, "vagrant.actions.vm.customize")
end
class VMFailedToBoot < VagrantError
status_code(21)
error_key(:failed_to_boot, "vagrant.actions.vm.boot")

View File

@ -313,6 +313,16 @@ en:
clear_shared_folders:
deleting: Cleaning previously set shared folders...
customize:
failure: |-
A customization command failed:
%{command}
The following error was experienced:
%{error}
Please fix this customization and try again.
running: Running any VM customizations...
destroy:
destroying: Destroying VM and associated drives...