diff --git a/lib/vagrant/action/vm/halt.rb b/lib/vagrant/action/vm/halt.rb index 38b806d5c..4615c49be 100644 --- a/lib/vagrant/action/vm/halt.rb +++ b/lib/vagrant/action/vm/halt.rb @@ -2,13 +2,18 @@ module Vagrant class Action module VM class Halt + include ExceptionCatcher + def initialize(app, env) @app = app end def call(env) if env["vm"].vm.running? - env["vm"].system.halt if !env["force"] + if !env["force"] + catch_action_exception(env) { env["vm"].system.halt } + return if env.error? + end if env["vm"].vm.state(true) != :powered_off env.logger.info "Forcing shutdown of VM..." diff --git a/lib/vagrant/action/vm/network.rb b/lib/vagrant/action/vm/network.rb index 3c3c184e9..f04e3917d 100644 --- a/lib/vagrant/action/vm/network.rb +++ b/lib/vagrant/action/vm/network.rb @@ -4,6 +4,8 @@ module Vagrant # Networking middleware for Vagrant. This enables host only # networking on VMs if configured as such. class Network + include ExceptionCatcher + def initialize(app, env) @app = app @env = env @@ -23,10 +25,12 @@ module Vagrant @app.call(env) if !env.error? && enable_network? - @env.logger.info "Enabling host only network..." - @env["vm"].system.prepare_host_only_network - @env.env.config.vm.network_options.compact.each do |network_options| - @env["vm"].system.enable_host_only_network(network_options) + catch_action_exception(env) do + @env.logger.info "Enabling host only network..." + @env["vm"].system.prepare_host_only_network + @env.env.config.vm.network_options.compact.each do |network_options| + @env["vm"].system.enable_host_only_network(network_options) + end end end end diff --git a/lib/vagrant/action/vm/share_folders.rb b/lib/vagrant/action/vm/share_folders.rb index 5cc395f6c..d5c1869a4 100644 --- a/lib/vagrant/action/vm/share_folders.rb +++ b/lib/vagrant/action/vm/share_folders.rb @@ -2,6 +2,8 @@ module Vagrant class Action module VM class ShareFolders + include ExceptionCatcher + def initialize(app, env) @app = app @env = env @@ -16,10 +18,12 @@ module Vagrant @app.call(env) if !env.error? - # Only mount and setup shared folders in the absense of an - # error - mount_shared_folders - setup_unison + catch_action_exception(env) do + # Only mount and setup shared folders in the absense of an + # error + mount_shared_folders + setup_unison + end end end