Skip to content

Commit

Permalink
Merge pull request #3622 from ActiveState/mitchell/dx-3178-2
Browse files Browse the repository at this point in the history
Recognize invalid input as a buildplanner error response.
  • Loading branch information
mitchell-as authored Jan 16, 2025
2 parents 151066a + f2995d6 commit 4dc43db
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions pkg/platform/api/buildplanner/response/createproject.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package response

import (
"github.com/ActiveState/cli/internal/errs"
"github.com/ActiveState/cli/internal/locale"
"github.com/ActiveState/cli/pkg/platform/api/buildplanner/types"
)

type ProjectCreated struct {
Expand All @@ -22,5 +24,9 @@ func ProcessProjectCreatedError(pcErr *ProjectCreated, fallbackMessage string) e
return errs.New(fallbackMessage)
}

if pcErr.Type == types.InvalidInputErrorType {
return locale.NewInputError("err_buildplanner_create_project", "Could not create project. Received message: {{.V0}}", pcErr.Message)
}

return &ProjectCreatedError{pcErr.Type, pcErr.Message}
}
3 changes: 2 additions & 1 deletion pkg/platform/api/buildplanner/response/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ func IsErrorResponse(errorType string) bool {
errorType == types.MergeConflictErrorType ||
errorType == types.RevertConflictErrorType ||
errorType == types.CommitNotInTargetHistoryErrorType ||
errorType == types.ComitHasNoParentErrorType
errorType == types.CommitHasNoParentErrorType ||
errorType == types.InvalidInputErrorType
}

// Error contains an error message.
Expand Down
3 changes: 2 additions & 1 deletion pkg/platform/api/buildplanner/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
MergeConflictErrorType = "MergeConflict"
RevertConflictErrorType = "RevertConflict"
CommitNotInTargetHistoryErrorType = "CommitNotInTargetHistory"
ComitHasNoParentErrorType = "CommitHasNoParent"
CommitHasNoParentErrorType = "CommitHasNoParent"
TargetNotFoundErrorType = "TargetNotFound"
InvalidInputErrorType = "InvalidInput"
)

0 comments on commit 4dc43db

Please sign in to comment.