Skip to content

Commit 25a13f2

Browse files
authored
fix: change error to have more details (#5724)
1 parent 90cc51b commit 25a13f2

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

engine/worker/cmd_tag.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,8 @@ func tagCmd() func(cmd *cobra.Command, args []string) {
7878

7979
resp, errDo := client.Do(req)
8080
if errDo != nil {
81-
sdk.Exit("command failed: %v\n", errDo)
81+
sdk.Exit("http call failed: %v\n", errDo)
8282
}
83-
8483
if resp.StatusCode >= 300 {
8584
body, err := ioutil.ReadAll(resp.Body)
8685
if err != nil {

engine/worker/internal/action/builtin_script.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,15 +228,15 @@ func RunScriptAction(ctx context.Context, wk workerruntime.Runtime, a sdk.Action
228228

229229
stdout, err := cmd.StdoutPipe()
230230
if err != nil {
231-
chanErr <- fmt.Errorf("Failure due to internal error: unable to capture stdout: %v", err)
231+
chanErr <- fmt.Errorf("failure due to internal error: unable to capture stdout: %v", err)
232232
res.Status = sdk.StatusFail
233233
chanRes <- res
234234
return
235235
}
236236

237237
stderr, err := cmd.StderrPipe()
238238
if err != nil {
239-
chanErr <- fmt.Errorf("Failure due to internal error: unable to capture stderr: %v", err)
239+
chanErr <- fmt.Errorf("failure due to internal error: unable to capture stderr: %v", err)
240240
res.Status = sdk.StatusFail
241241
chanRes <- res
242242
return
@@ -303,7 +303,7 @@ func RunScriptAction(ctx context.Context, wk workerruntime.Runtime, a sdk.Action
303303
case globalErr = <-chanErr:
304304
}
305305

306-
log.Info(ctx, "runScriptAction> %s %s", res.Status, res.Reason)
306+
log.Info(ctx, "runScriptAction> %s %s %v", res.Status, res.Reason, globalErr)
307307
return res, globalErr
308308
}
309309

engine/worker/internal/handler_tag.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func tagHandler(ctx context.Context, wk *CurrentWorker) http.HandlerFunc {
1616
ctx = workerruntime.SetStepName(ctx, wk.currentJob.currentStepName)
1717

1818
if err := r.ParseForm(); err != nil {
19-
writeError(w, r, err)
19+
writeError(w, r, sdk.NewErrorFrom(sdk.ErrInvalidData, "unable to parse form %v", err))
2020
return
2121
}
2222
tags := []sdk.WorkflowRunTag{}
@@ -27,10 +27,11 @@ func tagHandler(ctx context.Context, wk *CurrentWorker) http.HandlerFunc {
2727
})
2828
}
2929

30-
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
30+
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
3131
defer cancel()
3232
if err := wk.client.QueueJobTag(ctx, wk.currentJob.wJob.ID, tags); err != nil {
33-
writeError(w, r, err)
33+
newError := sdk.NewErrorFrom(sdk.ErrUnknownError, "unable to create tag on CDS: %v", err)
34+
writeError(w, r, newError)
3435
return
3536
}
3637
}

0 commit comments

Comments
 (0)