lib/sfn/command/destroy.rb in sfn-3.1.0 vs lib/sfn/command/destroy.rb in sfn-3.1.2

- old
+ new

@@ -43,15 +43,20 @@ ui.warn "Failed to locate requested stack: #{ui.color(stack_name, :bold)}" end end if config[:poll] if stacks.size == 1 + pstack = stacks.first begin - poll_stack(stacks.first) - rescue Miasma::Error::ApiError::RequestError => error - unless error.response.code == 404 - raise error + poll_stack(pstack) + stack = provider.connection.stacks.get(pstack) + stack.reload + if stack.state.to_s.end_with?("failed") + ui.error("Stack #{ui.color(pstack, :bold)} still exists after polling complete.") + raise "Failed to successfully destroy stack!" end + rescue Miasma::Error::ApiError::RequestError => error + # Ignore if stack cannot be reloaded end else ui.error "Stack polling is not available when multiple stack deletion is requested!" end end