-
Notifications
You must be signed in to change notification settings - Fork 82
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
Conversation
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
end | ||
|
||
{:error, {reason, report}} -> | ||
abort_installation(reason, report) | ||
{:error, {reason, report}} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
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.
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.
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.
This happened because the result of
download_and_compile
was notchecked, and not handled different if it ran into an error.
I updated the
download_and_compile
to not callabort_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