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

Conversation

tombruijn
Copy link
Member

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

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
@tombruijn tombruijn added the bug label Oct 15, 2021
@tombruijn tombruijn self-assigned this Oct 15, 2021
@tombruijn tombruijn marked this pull request as ready for review October 15, 2021 09:35
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?

@tombruijn tombruijn merged commit 7ccf75c into main Oct 15, 2021
unflxw added a commit that referenced this pull request Oct 15, 2021
In order to avoid having to repeatedly match against the errors'
structure in the "sad path", and to avoid nested `case`
statements, `with` is used to let the error fall through the
chain of calls. Mentioned in #693.
unflxw added a commit that referenced this pull request Oct 15, 2021
In order to avoid having to repeatedly match against the errors'
structure in the "sad path", and to avoid nested `case`
statements, `with` is used to let the error fall through the
chain of calls. Mentioned in #693.
jeffkreeftmeijer pushed a commit that referenced this pull request Oct 18, 2021
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extension installer will print mix of failure and success
4 participants