Skip to content

Commit

Permalink
fix: log the panic errors (#5023)
Browse files Browse the repository at this point in the history
* fix: log the panic errors

* fix: linter complain
  • Loading branch information
mindlesscloud authored Apr 24, 2023
1 parent 17cfca6 commit 5d81ae6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 6 additions & 3 deletions backend/core/runner/run_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ func RunTask(
default:
e = fmt.Errorf("%v", et)
}
if !dbPipeline.SkipOnFail {
err = errors.Default.Wrap(e, fmt.Sprintf("run task failed with panic (%s)", utils.GatherCallFrames(0)))
}
err = errors.Default.Wrap(e, fmt.Sprintf("run task failed with panic (%s)", utils.GatherCallFrames(0)))
logger.Error(err, "run task failed with panic")
}
finishedAt := time.Now()
spentSeconds := finishedAt.Unix() - beganAt.Unix()
Expand Down Expand Up @@ -114,6 +113,10 @@ func RunTask(
if dbe != nil {
logger.Error(dbe, "update pipeline state failed")
}
// not return err if the `SkipOnFail` is true
if dbPipeline.SkipOnFail {
err = nil
}
}()

// start execution
Expand Down
8 changes: 7 additions & 1 deletion backend/helpers/pluginhelper/api/worker_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package api

import (
"context"
"fmt"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -135,7 +136,12 @@ func (s *WorkerScheduler) checkError(err interface{}) {
if err == nil {
return
}
s.appendError(err.(error))
switch e := err.(type) {
case error:
s.appendError(e)
default:
s.appendError(fmt.Errorf("%v", e))
}
}

// HasError return if any error occurred
Expand Down

0 comments on commit 5d81ae6

Please sign in to comment.