Handling http errors from HTTPoison / Hackney

The underlying Hackney library can either return {:ok, status_code, headers, client_ref} or {:error, reason}. My interpretation of that is that you’ll get an :ok reply any time the connection is sufficiently successful to have a response code from the server, and :error when something goes so wrong (network failure, nonsensical server response, etc) that the response code isn’t available.