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

klesh pushed a commit to branch release-v0.12
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/release-v0.12 by this push:
     new 9f6c14dc fix: pipeline failed to handle panicking (#3143)
9f6c14dc is described below

commit 9f6c14dc467ece75fa8d9f64349e0646932c2fd8
Author: mappjzc <[email protected]>
AuthorDate: Tue Sep 20 18:59:03 2022 +0800

    fix: pipeline failed to handle panicking (#3143)
    
    pipeline failed to handle panicking
    cherry pick from
    f4eefc54b129bff9a41b125bcf7d2fa8bd24ea25
    #3142
    
    Nddtfjiang <[email protected]>
---
 runner/run_task.go | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

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

Reply via email to