Skip to content

Commit

Permalink
Merge pull request #2876 from ActiveState/DX-2224
Browse files Browse the repository at this point in the history
Recognize headless errors on requirement operations
  • Loading branch information
MDrakos authored Nov 10, 2023
2 parents 79e7849 + 9762cdf commit f8d87dc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/runbits/rationalize/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ var ErrNotAuthenticated = errors.New("not authenticated")

var ErrActionAborted = errors.New("aborted by user")

var ErrHeadless = errors.New("headless")

type ErrAPI struct {
Wrapped error
Code int
Expand Down
11 changes: 11 additions & 0 deletions internal/runbits/requirements/rationalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,20 @@ func (r *RequirementOperation) rationalizeError(err *error) {
buildPlannerErr.LocalizedError(),
errs.SetIf(buildPlannerErr.InputError(), errs.SetInput()))

// Project not found
case errors.Is(*err, rationalize.ErrNoProject):
*err = errs.WrapUserFacing(*err,
locale.Tr("err_no_project"),
errs.SetInput())

// Headless
case errors.Is(*err, rationalize.ErrHeadless):
*err = errs.WrapUserFacing(*err,
locale.Tl(
"err_requirement_headless",
"Cannot update requirements for a headless project. Please visit {{.V0}} to convert your project and try again.",
r.Project.URL(),
),
errs.SetInput())
}
}
3 changes: 3 additions & 0 deletions internal/runbits/requirements/requirements.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ func (r *RequirementOperation) ExecuteRequirementOperation(requirementName, requ
if r.Project == nil {
return rationalize.ErrNoProject
}
if r.Project.IsHeadless() {
return rationalize.ErrHeadless
}
out.Notice(locale.Tl("operating_message", "", r.Project.NamespaceString(), r.Project.Dir()))

switch nsType {
Expand Down

0 comments on commit f8d87dc

Please sign in to comment.