Sha256: 01b21b0760efeeef4bc637dbb0d0aa778a91f890ce3e2bb1168a97a66aae0321

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

require 'xmlsimple'

module SimpleDeploy
  class AWS
    class CloudFormation
      class Error

        def initialize(args)
          @logger    = SimpleDeploy.logger
          @exception = args[:exception]
        end

        def process
          @logger.debug "Object type = #{@exception.class}"
          if @exception.respond_to?(:response)
            unless @exception.response.body.empty?
              message = XmlSimple.xml_in @exception.response.body
              message['Error'].first['Message'].each do |msg|
                case msg
                when 'No updates are to be performed.'
                  @logger.info msg
                when /Template requires parameter(.*)/
                  @logger.info msg
                when /^Stack:(.*) does not exist$/
                  @logger.error msg
                  raise Exceptions::UnknownStack.new msg
                else
                  @logger.error msg
                  raise Exceptions::CloudFormationError.new msg
                end
              end
            else
              @logger.error "CloudFormation returned blank xml EXCEPTION => #{@exception.response.body}" 
              raise Exceptions::CloudFormationError.new "Cloudformation returned blank xml"
            end
          else
            @logger.error "Unknown exception from cloudformation #{@exception.inspect}"
            raise Exceptions::CloudFormationError.new "Unknown exception from cloudformation"
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simple_deploy-0.7.6.beta.1 lib/simple_deploy/aws/cloud_formation/error.rb