This is an automated email from the ASF dual-hosted git repository.

mappjzc pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new e927bfb5 fix: pipeline failed to handle panicking (#3142)
e927bfb5 is described below

commit e927bfb588e2f87e34c164f1343aaafc67402f25
Author: Klesh Wong <[email protected]>
AuthorDate: Tue Sep 20 18:05:52 2022 +0800

    fix: pipeline failed to handle panicking (#3142)
---
 runner/run_task.go | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/runner/run_task.go b/runner/run_task.go
index 28124877..d003187d 100644
--- a/runner/run_task.go
+++ b/runner/run_task.go
@@ -43,7 +43,7 @@ func RunTask(
        db *gorm.DB,
        progress chan core.RunningProgress,
        taskId uint64,
-) errors.Error {
+) (err errors.Error) {
        task := &models.Task{}
        if err := db.Find(task, taskId).Error; err != nil {
                return errors.Convert(err)
@@ -59,7 +59,14 @@ func RunTask(
        // make sure task status always correct even if it panicked
        defer func() {
                if r := recover(); r != nil {
-                       err = errors.Default.Wrap(r.(error), fmt.Sprintf("run 
task failed with panic (%s)", utils.GatherCallFrames(0)))
+                       var e error
+                       switch et := r.(type) {
+                       case error:
+                               e = et
+                       default:
+                               e = fmt.Errorf("%v", et)
+                       }
+                       err = errors.Default.Wrap(e, fmt.Sprintf("run task 
failed with panic (%s)", utils.GatherCallFrames(0)))
                }
                finishedAt := time.Now()
                spentSeconds := finishedAt.Unix() - beganAt.Unix()

Reply via email to