Skip to content

Commit

Permalink
fix(api): check err on as code (#3375)
Browse files Browse the repository at this point in the history
  • Loading branch information
yesnault authored and fsamin committed Sep 28, 2018
1 parent e3b2366 commit 924e808
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 1 addition & 6 deletions engine/api/workflow/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,7 @@ func CreateFromRepository(ctx context.Context, db *gorp.DbMap, store cache.Store
if opts.Hook != nil {
uuid = opts.Hook.WorkflowNodeHookUUID
}
allMsg, errE := extractWorkflow(ctx, db, store, p, w, ope, u, decryptFunc, uuid)
if errE != nil {
return nil, sdk.WrapError(err, "CreateFromRepository> Unable to extract workflow")
}

return allMsg, nil
return extractWorkflow(ctx, db, store, p, w, ope, u, decryptFunc, uuid)
}

func extractWorkflow(ctx context.Context, db *gorp.DbMap, store cache.Store, p *sdk.Project, w *sdk.Workflow, ope sdk.Operation, u *sdk.User, decryptFunc keys.DecryptFunc, hookUUID string) ([]sdk.Message, error) {
Expand Down
7 changes: 6 additions & 1 deletion engine/api/workflow_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"
"sort"
"strconv"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -694,7 +695,11 @@ func (api *API) postWorkflowRunHandler() service.Handler {
var errCreate error
asCodeInfosMsg, errCreate = workflow.CreateFromRepository(ctx, api.mustDB(), api.Cache, proj, wf, *opts, u, project.DecryptWithBuiltinKey)
if errCreate != nil {
return sdk.WrapError(errCreate, "postWorkflowRunHandler> Unable to get workflow from repository")
var msgListString string
if len(asCodeInfosMsg) > 0 {
msgListString = strings.Join(translate(r, asCodeInfosMsg), " ")
}
return sdk.WrapError(errCreate, "postWorkflowRunHandler> Unable to get workflow from repository.%s", msgListString)
}
} else {
var errl error
Expand Down

0 comments on commit 924e808

Please sign in to comment.