Sha256: 1f14388b8d03213515a1fdadac24bfcc398f8765e2619853b728c7432786c3c2

Contents?: true

Size: 595 Bytes

Versions: 1

Compression:

Stored size: 595 Bytes

Contents

require 'faraday'

module OpenAmplify

  module Response

    class RaiseClientError < Faraday::Response::Middleware

      def on_complete(env)
        status  = env[:status].to_i
        body    = env[:body]
        headers = env[:response_headers]

        case status
        when 400
          raise OpenAmplify::Error::BadRequest.new body, headers
        when 403
          raise OpenAmplify::Error::Forbidden.new body, headers
        when 413
          raise OpenAmplify::Error::RequestTooLarge.new body, headers
        end
      end

    end # RaiseClientError

  end # Response

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
openamplify-0.3.0 lib/openamplify/response/raise_client_error.rb