       {:ok, frame, state}
     else
       {:error, reason} ->
-        {:disconnect, reason, state}
+        {:disconnect, Error.exception(action: "execute", reason: reason), state}
     end
   end
 

  def connect(opts) do
    host = Keyword.fetch!(opts, :host) |> to_char_list()
    port = Keyword.get(opts, :port, 9042)
    case :gen_tcp.connect(host, port, @default_sock_opts, @default_timeout) do
      {:ok, sock} ->
        {:ok, options} = Utils.request_options(sock)
        :ok = Utils.startup_connection(sock, options)
        {:ok, %{sock: sock}}
      {:error, reason} ->
        {:error, Error.exception(action: "connect", reason: reason)}
    end
  end

  def checkout(state) do

      |> Protocol.encode_request(query)
      |> Frame.encode()

    with :ok <- :gen_tcp.send(sock, payload),
         {:ok, %Frame{} = frame} = Utils.recv_frame(sock) do
      {:ok, Protocol.decode_response(frame, query), state}
    else
      {:error, reason} ->
        {:disconnect, Error.exception(action: "prepare", reason: reason), state}
    end
  end

