Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show only failure message on install failure #693

Merged
merged 1 commit into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Now that the error is to be passed through as-is, there is no need to pattern-match the structure of the error on each case statement. We could have a catch-all err -> err, or we could use with instead of case, which passes non-matching values through:

with
  {:ok, {filename, report}} <- download_package(arch_config, report),
  {:ok, {filename, report}} <- verify_download_package(filename, arch_config[:checksum], report) do
    case extract_package(filename) do
      :ok -> compile(report)
      {:error, reason} -> {:error, {reason, report}}
    end
end

The same could be done in install/0, where it is also matching-and-aborting after every step.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@unflxw That would be a nice refactor. Can you send in a separate PR for that? Maybe a nice short distraction from the other PR you're working on?

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