From f34443f29af19b9e8dc40389225cf96770bfe913 Mon Sep 17 00:00:00 2001 From: mitchell Date: Mon, 23 Dec 2024 14:23:31 -0500 Subject: [PATCH 1/2] Recognize invalid input as a buildplanner error response. --- pkg/platform/api/buildplanner/response/shared.go | 3 ++- pkg/platform/api/buildplanner/types/errors.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/platform/api/buildplanner/response/shared.go b/pkg/platform/api/buildplanner/response/shared.go index 627bfcb949..0919014a33 100644 --- a/pkg/platform/api/buildplanner/response/shared.go +++ b/pkg/platform/api/buildplanner/response/shared.go @@ -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 } // NotFoundError represents an error that occurred because a resource was not found. diff --git a/pkg/platform/api/buildplanner/types/errors.go b/pkg/platform/api/buildplanner/types/errors.go index e3f234d30a..85146640a9 100644 --- a/pkg/platform/api/buildplanner/types/errors.go +++ b/pkg/platform/api/buildplanner/types/errors.go @@ -19,6 +19,7 @@ const ( MergeConflictErrorType = "MergeConflict" RevertConflictErrorType = "RevertConflict" CommitNotInTargetHistoryErrorType = "CommitNotInTargetHistory" - ComitHasNoParentErrorType = "CommitHasNoParent" + CommitHasNoParentErrorType = "CommitHasNoParent" TargetNotFoundErrorType = "TargetNotFound" + InvalidInputErrorType = "InvalidInput" ) From 27eb756c5f2eb7bd4f7ea01f912a44338323709f Mon Sep 17 00:00:00 2001 From: mitchell Date: Wed, 15 Jan 2025 13:06:28 -0500 Subject: [PATCH 2/2] Mark invalid input errors for project creation as input errors. --- pkg/platform/api/buildplanner/response/createproject.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/platform/api/buildplanner/response/createproject.go b/pkg/platform/api/buildplanner/response/createproject.go index 9531aa2efc..9c9ed79c3d 100644 --- a/pkg/platform/api/buildplanner/response/createproject.go +++ b/pkg/platform/api/buildplanner/response/createproject.go @@ -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 { @@ -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} }