Refactor error thrown when a git command fails #622
Merged
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.
Your checklist for this pull request
🚨Please review the guidelines for contributing to this repository.
Description
In preparation for refactoring how Git commands are executed by this gem (see #617), add two new classes:
Git::FailedErrorandGit::SignaledErrorto indicate different failure conditions when running the Git CLI.Git::FailedErroris raised when thegitcommand returns a non-zero exitstatus.Git::Signaledis raised when thegitcommand fails because of an uncaught signal (like a kill signal).Both of these new errors derive from
Git::GitExecuteErrorso existing code that was rescuing this error will still work as before.Both of these new errors expect to be initialized with an instance of another new class added in this PR:
Git::CommandLineResult. Objects of this class capture:The intent is to give callers better context as to the type of error (non-zero exitstatus vs. uncaught signal) as well as provide better context as to the command executed, the ending status of the process (including exitstatus or signal #), and the captured command line output.
Git::FailedErrorhas been fully integrated intoGit::Lib#command. Any situation where aGit::GitExecuteErrorwould have been raised before now raises aGit::FailedError. As mentioned before, sinceGit::FailedErroris a subclass ofGit::GitExecuteError, no change is required to client code.Git::SignaledErrorhas not yet be integrated intoGit::Lib#command.