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