Skip to content

Commit

Permalink
fix(api): improve display err to user (#5680)
Browse files Browse the repository at this point in the history
Signed-off-by: Yvonnick Esnault <[email protected]>
  • Loading branch information
yesnault authored Feb 11, 2021
1 parent 30b6957 commit b643bee
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions engine/api/workflowtemplate/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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))
}
}

Expand All @@ -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))
}
}

Expand All @@ -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))
}
}

Expand Down

0 comments on commit b643bee

Please sign in to comment.