From 3d3e1b358601b16bf462541b6efbe57273237bbb Mon Sep 17 00:00:00 2001 From: Tom de Bruijn Date: Fri, 15 Oct 2021 10:41:59 +0200 Subject: [PATCH] Show only failure message on install failure When the extension installation would fail, the installer would first print a failure message and then a success message. ``` AppSignal installation failed: Could not download archive from any of our mirrors. # Long error message 09:08:07.699 [debug] AppSignal for Elixir 2.2.3 succesfully installed! ``` This happened because the result of `download_and_compile` was not checked, and not handled different if it ran into an error. I updated the `download_and_compile` to not call `abort_installation` directly, but instead let the parent function handle that, along with the success scenario. Now all the failure scenarios (that eventually call) `abort_installation` are handled in the same way. Fixes #686 --- .../fix-mixed-install-result-message.md | 5 ++++ mix_helpers.exs | 24 +++++++++++-------- 2 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 .changesets/fix-mixed-install-result-message.md diff --git a/.changesets/fix-mixed-install-result-message.md b/.changesets/fix-mixed-install-result-message.md new file mode 100644 index 000000000..ee0cccad2 --- /dev/null +++ b/.changesets/fix-mixed-install-result-message.md @@ -0,0 +1,5 @@ +--- +bump: "patch" +--- + +Fix install result message to no longer show a success message when an installation failure occurred. diff --git a/mix_helpers.exs b/mix_helpers.exs index 579367510..5dd7d6980 100644 --- a/mix_helpers.exs +++ b/mix_helpers.exs @@ -24,14 +24,18 @@ defmodule Mix.Appsignal.Helper do {:ok, {arch, report}} -> case find_package_source(arch, report) do {:ok, {arch_config, %{build: %{source: "remote"}} = report}} -> - download_and_compile(arch_config, report) + case download_and_compile(arch_config, report) do + :ok -> + Logger.debug(""" + AppSignal for Elixir #{Mix.Project.config()[:version]} succesfully installed! + If you're upgrading from version 1.x, please review our upgrade guide: - Logger.debug(""" - AppSignal for Elixir #{Mix.Project.config()[:version]} succesfully installed! - If you're upgrading from version 1.x, please review our upgrade guide: + https://docs.appsignal.com/elixir/installation/upgrading-from-1.x-to-2.x.html + """) - https://docs.appsignal.com/elixir/installation/upgrading-from-1.x-to-2.x.html - """) + {:error, {reason, report}} -> + abort_installation(reason, report) + end {:ok, report} -> # Installation using already downloaded package of the extension @@ -114,15 +118,15 @@ defmodule Mix.Appsignal.Helper do compile(report) {:error, reason} -> - abort_installation(reason, report) + {:error, {reason, report}} end {:error, {reason, report}} -> - abort_installation(reason, report) + {:error, {reason, report}} end {:error, {reason, report}} -> - abort_installation(reason, report) + {:error, {reason, report}} end end @@ -276,7 +280,7 @@ defmodule Mix.Appsignal.Helper do #{output} """ - abort_installation(message, report) + {:error, {message, report}} end end