Sha256: 324da2a0d8d2899665eb0d47eff39e7e1dcaf7922a4d487b23751d4d2e9560e2

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

module Ecoportal
  module API
    module Common
      class Client
        module Error
          module Checks
            private

            def unexpected_server_error_code?(code)
              return true unless code
              return true if (code >= 500) && (code <= 599)

              code <= 99
            end

            # Sometimes response body is wrong but status code
            # doesn't reflect. Let it retry
            def some_unexpected_error?(response)
              return true if unexpected_server_error_code?(response.status)

              unexpected_body?(response)
            end

            def unexpected_body?(response)
              response.body.nil?.tap do |wrong|
                next unless wrong

                msg  = "Received non json body in response "
                msg << "(#{response.src_body.class}):\n "
                msg << response.src_body
                puts
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ecoportal-api-0.10.6 lib/ecoportal/api/common/client/error/checks.rb
ecoportal-api-0.10.5 lib/ecoportal/api/common/client/error/checks.rb
ecoportal-api-0.10.4 lib/ecoportal/api/common/client/error/checks.rb
ecoportal-api-0.10.3 lib/ecoportal/api/common/client/error/checks.rb