handle error with github network

This commit is contained in:
Jifffffy 2023-05-29 10:01:40 +08:00 committed by GitHub
parent 712204ca17
commit 0c823a18ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -90,20 +90,18 @@ defmodule LiveBeats.Github do
defp secret, do: LiveBeats.config([:github, :client_secret]) defp secret, do: LiveBeats.config([:github, :client_secret])
defp http(host, method, path, query, headers, body \\ "") do defp http(host, method, path, query, headers, body \\ "") do
{:ok, conn} = Mint.HTTP.connect(:https, host, 443)
path = path <> "?" <> URI.encode_query([{:client_id, client_id()} | query]) path = path <> "?" <> URI.encode_query([{:client_id, client_id()} | query])
{:ok, conn, ref} = with {:ok, conn} <- Mint.HTTP.connect(:https, host, 443),
Mint.HTTP.request( {:ok, conn, ref} <-
conn, Mint.HTTP.request(
method, conn,
path, method,
headers, path,
body headers,
) body
),
receive_resp(conn, ref, nil, nil, false) do: receive_resp(conn, ref, nil, nil, false)
end end
defp receive_resp(conn, ref, status, data, done?) do defp receive_resp(conn, ref, status, data, done?) do