Sha256: 03b5df41be5b07b442e1765e881bba4a2434b3e27750f6b02e49d0f4da192c49

Contents?: true

Size: 1.05 KB

Versions: 24

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module Aws
  class ErrorHandler < Seahorse::Client::Handler

    private

    def error(context)
      body = context.http_response.body_contents
      if body.empty?
        code, message, data = http_status_error(context)
      else
        code, message, data = extract_error(body, context)
      end
      build_error(context, code, message, data)
    end

    def build_error(context, code, message, data)
      errors_module = context.client.class.errors_module
      errors_module.error_class(code).new(context, message, data)
    end

    def http_status_error(context)
      [http_status_error_code(context), '', EmptyStructure.new]
    end

    def http_status_error_code(context)
      status_code = context.http_response.status_code
      {
        302 => 'MovedTemporarily',
        304 => 'NotModified',
        400 => 'BadRequest',
        403 => 'Forbidden',
        404 => 'NotFound',
        412 => 'PreconditionFailed',
        413 => 'RequestEntityTooLarge',
      }[status_code] || "Http#{status_code}Error"
    end

  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
aws-sdk-core-3.214.0 lib/aws-sdk-core/error_handler.rb
aws-sdk-core-3.213.0 lib/aws-sdk-core/error_handler.rb
aws-sdk-core-3.212.0 lib/aws-sdk-core/error_handler.rb
aws-sdk-core-3.211.0 lib/aws-sdk-core/error_handler.rb
aws-sdk-core-3.210.0 lib/aws-sdk-core/error_handler.rb
aws-sdk-core-3.209.1 lib/aws-sdk-core/error_handler.rb
aws-sdk-core-3.209.0 lib/aws-sdk-core/error_handler.rb
aws-sdk-core-3.208.0 lib/aws-sdk-core/error_handler.rb
aws-sdk-core-3.207.0 lib/aws-sdk-core/error_handler.rb
aws-sdk-core-3.206.0 lib/aws-sdk-core/error_handler.rb
aws-sdk-core-3.205.0 lib/aws-sdk-core/error_handler.rb
aws-sdk-core-3.204.0 lib/aws-sdk-core/error_handler.rb
aws-sdk-core-3.203.0 lib/aws-sdk-core/error_handler.rb
aws-sdk-core-3.202.2 lib/aws-sdk-core/error_handler.rb
aws-sdk-core-3.202.1 lib/aws-sdk-core/error_handler.rb
aws-sdk-core-3.202.0 lib/aws-sdk-core/error_handler.rb
aws-sdk-core-3.201.5 lib/aws-sdk-core/error_handler.rb
aws-sdk-core-3.201.4 lib/aws-sdk-core/error_handler.rb
aws-sdk-core-3.201.3 lib/aws-sdk-core/error_handler.rb
aws-sdk-core-3.201.2 lib/aws-sdk-core/error_handler.rb