From 3564971cb8eb6b33b7a4d0f049ce8e99ebbd2374 Mon Sep 17 00:00:00 2001 From: James van Lommel Date: Fri, 22 Dec 2023 10:38:39 -0500 Subject: [PATCH] fix: handle when auto updater receives a non-200 from GitHub API (#351) Fixes #350 Co-authored-by: James VL --- lib/next_ls/updater.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/next_ls/updater.ex b/lib/next_ls/updater.ex index 7eed4491..b8d13a98 100644 --- a/lib/next_ls/updater.ex +++ b/lib/next_ls/updater.ex @@ -17,7 +17,7 @@ defmodule NextLS.Updater do retry = Keyword.get(opts, :retry, :safe) case Req.get("/repos/elixir-tools/next-ls/releases/latest", base_url: api_host, retry: retry) do - {:ok, %{body: %{"tag_name" => "v" <> version = tag}}} -> + {:ok, %{status: 200, body: %{"tag_name" => "v" <> version = tag}}} -> with {:ok, latest_version} <- Version.parse(version), :gt <- Version.compare(latest_version, current_version) do with :ok <- File.rename(binpath, binpath <> "-#{Version.to_string(current_version)}"), @@ -65,7 +65,7 @@ defmodule NextLS.Updater do end end - {:error, error} -> + {_, error} -> NextLS.Logger.error( logger, "Failed to retrieve the latest version number of Next LS from the GitHub API: #{inspect(error)}"