Skip to content

Commit f6e2275

Browse files
committed
Recognize planning errors when evaluating a build expression.
1 parent d90dc9a commit f6e2275

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pkg/platform/api/buildplanner/response/commit.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ import (
1313
func ProcessBuildError(build *BuildResponse, fallbackMessage string) error {
1414
logging.Debug("ProcessBuildError: build.Type=%s", build.Type)
1515
if build.Type == types.PlanningErrorType {
16-
return processPlanningError(build.Message, build.SubErrors)
16+
return ProcessPlanningError(build.Message, build.SubErrors)
1717
} else if build.Error == nil {
1818
return errs.New(fallbackMessage)
1919
}
2020

2121
return locale.NewInputError("err_buildplanner_build", "Encountered error processing build response")
2222
}
2323

24-
func processPlanningError(message string, subErrors []*BuildExprError) error {
24+
func ProcessPlanningError(message string, subErrors []*BuildExprError) error {
2525
var errs []string
2626
var isTransient bool
2727

pkg/platform/model/buildplanner/evaluate.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/ActiveState/cli/pkg/buildscript"
1212
"github.com/ActiveState/cli/pkg/platform/api/buildplanner/request"
1313
"github.com/ActiveState/cli/pkg/platform/api/buildplanner/response"
14+
"github.com/ActiveState/cli/pkg/platform/api/buildplanner/types"
1415
)
1516

1617
func (bp *BuildPlanner) Evaluate(org, project string, script *buildscript.BuildScript) error {
@@ -31,6 +32,12 @@ func (bp *BuildPlanner) Evaluate(org, project string, script *buildscript.BuildS
3132
if err != nil {
3233
return processBuildPlannerError(err, "Failed to evaluate build expression")
3334
}
35+
if response.IsErrorResponse(resp.Type) {
36+
if resp.Type == types.PlanningErrorType {
37+
return response.ProcessPlanningError(resp.Message, resp.SubErrors)
38+
}
39+
return locale.NewError("err_buildplanner_evaluate", "Encountered error evaluating build plan: {{.V0}}", resp.Message)
40+
}
3441
sessionId = resp.SessionID
3542
if resp.Status != raw.Planning && resp.Status != raw.Started {
3643
return nil

0 commit comments

Comments
 (0)