From b643bee3a1f306dbfc569248635caba4212240a3 Mon Sep 17 00:00:00 2001 From: Yvonnick Esnault Date: Thu, 11 Feb 2021 10:08:31 +0100 Subject: [PATCH] fix(api): improve display err to user (#5680) Signed-off-by: Yvonnick Esnault --- engine/api/workflowtemplate/execute.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/engine/api/workflowtemplate/execute.go b/engine/api/workflowtemplate/execute.go index c517f6de66..d9ecb4a265 100644 --- a/engine/api/workflowtemplate/execute.go +++ b/engine/api/workflowtemplate/execute.go @@ -190,7 +190,7 @@ func Execute(wt sdk.WorkflowTemplate, instance sdk.WorkflowTemplateInstance) (ex } result.Workflow, err = exportentities.UnmarshalWorkflow([]byte(workflowYaml), exportentities.FormatYAML) if err != nil { - return result, sdk.NewErrorWithStack(err, sdk.NewErrorFrom(sdk.ErrWrongRequest, "cannot parse generated workflow")) + return result, sdk.NewError(sdk.ErrWrongRequest, fmt.Errorf("cannot parse generated workflow: %v", err)) } for i := range parsedTemplate.Pipelines { @@ -199,7 +199,7 @@ func Execute(wt sdk.WorkflowTemplate, instance sdk.WorkflowTemplateInstance) (ex return result, err } if err := yaml.Unmarshal([]byte(pipelineYaml), &result.Pipelines[i]); err != nil { - return result, sdk.NewErrorWithStack(err, sdk.NewErrorFrom(sdk.ErrWrongRequest, "cannot parse generated pipeline")) + return result, sdk.NewError(sdk.ErrWrongRequest, fmt.Errorf("cannot parse generated pipeline: %v", err)) } } @@ -209,7 +209,7 @@ func Execute(wt sdk.WorkflowTemplate, instance sdk.WorkflowTemplateInstance) (ex return result, err } if err := yaml.Unmarshal([]byte(applicationYaml), &result.Applications[i]); err != nil { - return result, sdk.NewErrorWithStack(err, sdk.NewErrorFrom(sdk.ErrWrongRequest, "cannot parse generated application")) + return result, sdk.NewError(sdk.ErrWrongRequest, fmt.Errorf("cannot parse generated application: %v", err)) } } @@ -219,7 +219,7 @@ func Execute(wt sdk.WorkflowTemplate, instance sdk.WorkflowTemplateInstance) (ex return result, err } if err := yaml.Unmarshal([]byte(environmentYaml), &result.Environments[i]); err != nil { - return result, sdk.NewErrorWithStack(err, sdk.NewErrorFrom(sdk.ErrWrongRequest, "cannot parse generated environment")) + return result, sdk.NewError(sdk.ErrWrongRequest, fmt.Errorf("cannot parse generated environment: %v", err)) } }