Catch remaining locations with action exceptions

This commit is contained in:
Mitchell Hashimoto 2010-07-08 22:01:35 -07:00
parent a0a6230455
commit 65cd1afd4f
3 changed files with 22 additions and 9 deletions

View File

@ -2,13 +2,18 @@ module Vagrant
class Action class Action
module VM module VM
class Halt class Halt
include ExceptionCatcher
def initialize(app, env) def initialize(app, env)
@app = app @app = app
end end
def call(env) def call(env)
if env["vm"].vm.running? 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 if env["vm"].vm.state(true) != :powered_off
env.logger.info "Forcing shutdown of VM..." env.logger.info "Forcing shutdown of VM..."

View File

@ -4,6 +4,8 @@ module Vagrant
# Networking middleware for Vagrant. This enables host only # Networking middleware for Vagrant. This enables host only
# networking on VMs if configured as such. # networking on VMs if configured as such.
class Network class Network
include ExceptionCatcher
def initialize(app, env) def initialize(app, env)
@app = app @app = app
@env = env @env = env
@ -23,6 +25,7 @@ module Vagrant
@app.call(env) @app.call(env)
if !env.error? && enable_network? if !env.error? && enable_network?
catch_action_exception(env) do
@env.logger.info "Enabling host only network..." @env.logger.info "Enabling host only network..."
@env["vm"].system.prepare_host_only_network @env["vm"].system.prepare_host_only_network
@env.env.config.vm.network_options.compact.each do |network_options| @env.env.config.vm.network_options.compact.each do |network_options|
@ -30,6 +33,7 @@ module Vagrant
end end
end end
end end
end
# Verifies that there is no collision with a bridged network interface # Verifies that there is no collision with a bridged network interface
# for the given network options. # for the given network options.

View File

@ -2,6 +2,8 @@ module Vagrant
class Action class Action
module VM module VM
class ShareFolders class ShareFolders
include ExceptionCatcher
def initialize(app, env) def initialize(app, env)
@app = app @app = app
@env = env @env = env
@ -16,12 +18,14 @@ module Vagrant
@app.call(env) @app.call(env)
if !env.error? if !env.error?
catch_action_exception(env) do
# Only mount and setup shared folders in the absense of an # Only mount and setup shared folders in the absense of an
# error # error
mount_shared_folders mount_shared_folders
setup_unison setup_unison
end end
end end
end
# This method returns an actual list of VirtualBox shared # This method returns an actual list of VirtualBox shared
# folders to create and their proper path. # folders to create and their proper path.