Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently a UI instance is passed around to all parts of shuttle allowing layers
to report messages to the user. It also provides methods ExitWithError,
ExitWithErrorCode and CheckIfError which are fatal messages stopping shuttle
completely by calling os.Exit. This makes shuttle in it self hard to test and
provides unclear exit paths of the code.
This change contains multiple changes to fix above issues.
The methods from package ui are removed and instead a checkError function is
added to package cmd which is responsible for selecting an exit code based on
the error. This greatly improvoes maintainability of the code and makes it
easier to reason about any possible exit paths from code in packages of pkg/*.
Some dead code is removed from package pkg/config. An unused CheckIfError
function was laying around here and as this change moves functionality around
related to the nature of this one I figured it was worth removing now.
During the change I found a couple of bugs in the error reporting that is fixed
as well.
When using command 'run' with invalid arguments exit code 1 indicating a shuttle
failure is reported instead of 2 indicating bad user input.
If a plan cannot be fetched due to an unknown protocol a panic is thrown. It now
returns an ExitCode error indicating bad user input.
Errors around the .shuttle directory are now also detected and propagated
instead of silently ignored.