Skip to content

Commit

Permalink
Show only failure message on install failure (#693)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tombruijn authored Oct 15, 2021
1 parent e7d676a commit 7ccf75c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changesets/fix-mixed-install-result-message.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
bump: "patch"
---

Fix install result message to no longer show a success message when an installation failure occurred.
24 changes: 14 additions & 10 deletions mix_helpers.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -276,7 +280,7 @@ defmodule Mix.Appsignal.Helper do
#{output}
"""

abort_installation(message, report)
{:error, {message, report}}
end
end

Expand Down

0 comments on commit 7ccf75c

Please sign in to comment.