Warden properly handles interrupts
This commit is contained in:
parent
71101c9d3d
commit
0094f066ca
|
@ -20,6 +20,7 @@ module Vagrant
|
||||||
begin
|
begin
|
||||||
# Call the next middleware in the sequence, appending to the stack
|
# Call the next middleware in the sequence, appending to the stack
|
||||||
# of "recoverable" middlewares in case something goes wrong!
|
# of "recoverable" middlewares in case something goes wrong!
|
||||||
|
raise Errors::VagrantInterrupt.new if env.interrupted?
|
||||||
@stack.unshift(@actions.shift).first.call(env)
|
@stack.unshift(@actions.shift).first.call(env)
|
||||||
raise Errors::VagrantInterrupt.new if env.interrupted?
|
raise Errors::VagrantInterrupt.new if env.interrupted?
|
||||||
rescue
|
rescue
|
||||||
|
@ -34,6 +35,10 @@ module Vagrant
|
||||||
@stack.each do |act|
|
@stack.each do |act|
|
||||||
act.recover(env) if act.respond_to?(:recover)
|
act.recover(env) if act.respond_to?(:recover)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Clear stack so that warden down the middleware chain doesn't
|
||||||
|
# rescue again.
|
||||||
|
@stack.clear
|
||||||
end
|
end
|
||||||
|
|
||||||
def finalize_action(action, env)
|
def finalize_action(action, env)
|
||||||
|
|
|
@ -32,7 +32,7 @@ module Vagrant
|
||||||
def initialize(message=nil, *args)
|
def initialize(message=nil, *args)
|
||||||
message = { :_key => message } if message && !message.is_a?(Hash)
|
message = { :_key => message } if message && !message.is_a?(Hash)
|
||||||
message = { :_key => error_key, :_namespace => error_namespace }.merge(message || {})
|
message = { :_key => error_key, :_namespace => error_namespace }.merge(message || {})
|
||||||
message = translate_error(message) if message[:_key]
|
message = translate_error(message)
|
||||||
|
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
@ -49,6 +49,7 @@ module Vagrant
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def translate_error(opts)
|
def translate_error(opts)
|
||||||
|
return nil if !opts[:_key]
|
||||||
I18n.t("#{opts[:_namespace]}.#{opts[:_key]}", opts)
|
I18n.t("#{opts[:_namespace]}.#{opts[:_key]}", opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue