     s = State.state
 
     case resp do
-      {:ok, %HTTPoison.Response{status_code: code} = resp} when code < 300 ->
+      {:ok, %HTTPoison.Response{status_code: status}} when status < 300 ->
         resp
 
         # TODO:


  require Logger

  alias ESx.Transport.{State, Sniffer, Connection}

  defstruct [
    method: "GET",

        # connection.healthy! if connection.failures > 0

      # retry_on_status
      {:ok, %HTTPoison.Response{status_code: status}} when status >= 300 ->
        if tries <= s.max_retries and status in s.retry_on_status do
          Logger.warn "[retry_on_status] Attempt #{tries} to get response from #{uri}"

          do_perform_request method, path, params, body, tries
        else
          msg = "[retry_on_status] Couldn't get response from #{uri} after #{tries} tries"

          Logger.error msg
          {:error, %ServerError{message: msg, status: status}}
        end

      # failure
      {:error, %HTTPoison.Error{reason: reason} = perr} ->
        if tries <= s.max_retries do
          Logger.warn "[#{reason}] Attempt #{tries} connecting to #{uri}"

          do_perform_request method, path, params, body, tries
        else
          Logger.error "[#{reason}] Couldn't connect to #{uri} after #{tries} tries"

          {:error, perr}
        end
    end
