-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2818 from ActiveState/DX-2149
- Loading branch information
Showing
14 changed files
with
256 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package requirements | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/ActiveState/cli/internal/errs" | ||
"github.com/ActiveState/cli/internal/locale" | ||
"github.com/ActiveState/cli/pkg/localcommit" | ||
bpModel "github.com/ActiveState/cli/pkg/platform/api/buildplanner/model" | ||
"github.com/ActiveState/cli/pkg/platform/model" | ||
) | ||
|
||
func (r *RequirementOperation) rationalizeError(err *error) { | ||
var localCommitFileErr *localcommit.ErrLocalCommitFile | ||
var tooManyMatchesErr *model.ErrTooManyMatches | ||
var noMatchesErr *ErrNoMatches | ||
var buildPlannerErr *bpModel.BuildPlannerError | ||
|
||
switch { | ||
case err == nil: | ||
return | ||
|
||
// Local commit file not found or malformed | ||
case errors.As(*err, &localCommitFileErr): | ||
*err = errs.WrapUserFacing(*err, | ||
locale.Tr("err_local_commit_file", localCommitFileErr.File), | ||
errs.SetInput()) | ||
|
||
// Too many matches | ||
case errors.As(*err, &tooManyMatchesErr): | ||
*err = errs.WrapUserFacing(*err, | ||
locale.Tr("err_searchingredient_toomany", tooManyMatchesErr.Query), | ||
errs.SetInput()) | ||
|
||
// No matches, and no alternate suggestions | ||
case errors.As(*err, &noMatchesErr) && noMatchesErr.Alternatives == nil: | ||
*err = errs.WrapUserFacing(*err, | ||
locale.Tr("package_ingredient_alternatives_nosuggest", noMatchesErr.Query), | ||
errs.SetInput()) | ||
|
||
// No matches, but have alternate suggestions | ||
case errors.As(*err, &noMatchesErr) && noMatchesErr.Alternatives != nil: | ||
*err = errs.WrapUserFacing(*err, | ||
locale.Tr("package_ingredient_alternatives", noMatchesErr.Query, *noMatchesErr.Alternatives), | ||
errs.SetInput()) | ||
|
||
// We communicate buildplanner errors verbatim as the intend is that these are curated by the buildplanner | ||
case errors.As(*err, &buildPlannerErr): | ||
*err = errs.WrapUserFacing(*err, | ||
buildPlannerErr.LocalizedError(), | ||
errs.SetIf(buildPlannerErr.InputError(), errs.SetInput())) | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.