Warden properly handles interrupts

This commit is contained in:
Mitchell Hashimoto 2010-09-01 16:15:24 -07:00
parent 71101c9d3d
commit 0094f066ca
2 changed files with 7 additions and 1 deletions

View File

@ -20,6 +20,7 @@ module Vagrant
begin
# Call the next middleware in the sequence, appending to the stack
# of "recoverable" middlewares in case something goes wrong!
raise Errors::VagrantInterrupt.new if env.interrupted?
@stack.unshift(@actions.shift).first.call(env)
raise Errors::VagrantInterrupt.new if env.interrupted?
rescue
@ -34,6 +35,10 @@ module Vagrant
@stack.each do |act|
act.recover(env) if act.respond_to?(:recover)
end
# Clear stack so that warden down the middleware chain doesn't
# rescue again.
@stack.clear
end
def finalize_action(action, env)

View File

@ -32,7 +32,7 @@ module Vagrant
def initialize(message=nil, *args)
message = { :_key => message } if message && !message.is_a?(Hash)
message = { :_key => error_key, :_namespace => error_namespace }.merge(message || {})
message = translate_error(message) if message[:_key]
message = translate_error(message)
super
end
@ -49,6 +49,7 @@ module Vagrant
protected
def translate_error(opts)
return nil if !opts[:_key]
I18n.t("#{opts[:_namespace]}.#{opts[:_key]}", opts)
end
end