Sha256: efccc4674a16d1c5e3b1fb37506756ffc54ed27be2f1c0ef570268bff8a95cf4

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

require 'forwardable'

module Peddler
  # @!visibility private
  module Errors
    # These error codes are common to all Amazon MWS API sections.
    #
    # @see https://docs.developer.amazonservices.com/en_US/dev_guide/DG_Errors.html
    #
    # There are quite a few other error types they do not explicitly document
    # above. I decided not to define any for the sake of consistency and future
    # maintenance.
    CODES = %w[
      AccessDenied
      InputStreamDisconnected
      InternalError
      InvalidAccessKeyId
      InvalidAddress
      InvalidParameterValue
      QuotaExceeded
      RequestThrottled
      SignatureDoesNotMatch
    ].freeze

    # @!visibility private
    class Error < StandardError
      extend Forwardable

      attr_reader :cause

      def initialize(msg = nil, cause = nil)
        @cause = cause
        super msg
      end

      def_delegator :cause, :response
    end

    CODES.each do |name|
      const_set name, Class.new(Error)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
peddler-2.4.5 lib/peddler/errors/error.rb
peddler-2.4.4 lib/peddler/errors/error.rb
peddler-2.4.3 lib/peddler/errors/error.rb
peddler-2.4.1 lib/peddler/errors/error.rb
peddler-2.4.0 lib/peddler/errors/error.rb
peddler-2.3.0 lib/peddler/errors/error.rb