Sha256: 2420d8e56f1e0d94ccce085c0f1c43e39576fa51301167ac04e94ce2e57272fb

Contents?: true

Size: 458 Bytes

Versions: 5

Compression:

Stored size: 458 Bytes

Contents

# frozen_string_literal: true
require 'amazing_print'
module Usps
  module Faraday
    module Response
      class RaiseError < ::Faraday::Response::Middleware
        def on_complete(env)
          raise Usps::Api::Errors::TooManyRequestsError, env.response if env.status == 429
          return unless (body = env.body) && body['Error']

          raise Usps::Api::Errors::UspsError.new(body['Error'], env.response)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
usps-ruby-client-0.2.0 lib/usps/faraday/response/raise_error.rb
usps-ruby-client-0.1.3 lib/usps/faraday/response/raise_error.rb
usps-ruby-client-0.1.2 lib/usps/faraday/response/raise_error.rb
usps-ruby-client-0.1.1 lib/usps/faraday/response/raise_error.rb
usps-ruby-client-0.1.0 lib/usps/faraday/response/raise_error.rb