From fca80204f49d7431bc6111e337a9c96d9abd330d Mon Sep 17 00:00:00 2001 From: ashish sonam Date: Mon, 4 Dec 2023 15:06:43 +0530 Subject: [PATCH] returned error with proper status code --- pkg/appWorkflow/AppWorkflowService.go | 1 + pkg/pipeline/CiHandler.go | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/appWorkflow/AppWorkflowService.go b/pkg/appWorkflow/AppWorkflowService.go index b4ceedb2f7..cec9f6f96a 100644 --- a/pkg/appWorkflow/AppWorkflowService.go +++ b/pkg/appWorkflow/AppWorkflowService.go @@ -253,6 +253,7 @@ func (impl AppWorkflowServiceImpl) DeleteAppWorkflow(appWorkflowId int, userId i } if len(mappingForCI) > 0 { return &util.ApiError{ + Code: "400", InternalMessage: "Workflow contains pipelines. First delete all pipelines in the workflow.", UserDetailMessage: fmt.Sprintf("Workflow contains pipelines. First delete all pipelines in the workflow."), UserMessage: fmt.Sprintf("Workflow contains pipelines. First delete all pipelines in the workflow.")} diff --git a/pkg/pipeline/CiHandler.go b/pkg/pipeline/CiHandler.go index 19fdde0b2e..1326601d69 100644 --- a/pkg/pipeline/CiHandler.go +++ b/pkg/pipeline/CiHandler.go @@ -588,7 +588,11 @@ func (impl *CiHandlerImpl) CancelBuild(workflowId int) (int, error) { } if !(string(v1alpha1.NodePending) == workflow.Status || string(v1alpha1.NodeRunning) == workflow.Status) { impl.Logger.Warn("cannot cancel build, build not in progress") - return 0, errors.New("cannot cancel build, build not in progress") + return 0, &util.ApiError{ + Code: "400", + UserMessage: "cannot cancel build, build not in progress", + InternalMessage: "cannot cancel build, build not in progress", + } } isExt := workflow.Namespace != DefaultCiWorkflowNamespace var env *repository3.Environment