fix(task): 改进任务失败时的错误信息记录
This commit is contained in:
+10
-3
@@ -263,10 +263,17 @@ func PullTaskResult(ctx context.Context, body map[string]any, queryConfig map[st
|
|||||||
}
|
}
|
||||||
|
|
||||||
if matchStatus(statusStr, statusValues["failed"]) {
|
if matchStatus(statusStr, statusValues["failed"]) {
|
||||||
g.Log().Errorf(ctx, "[PullTaskResult] 任务失败 taskID=%s", taskID)
|
errMsg := gconv.String(gjson.New(result).Get("error.message").Val())
|
||||||
return result, fmt.Errorf("任务失败")
|
if errMsg == "" {
|
||||||
|
errMsg = gconv.String(gjson.New(result).Get("error").Val())
|
||||||
|
}
|
||||||
|
if errMsg == "" {
|
||||||
|
rawBytes, _ := json.Marshal(result)
|
||||||
|
errMsg = string(rawBytes)
|
||||||
|
}
|
||||||
|
g.Log().Errorf(ctx, "[PullTaskResult] 任务失败 taskID=%s err=%s", taskID, errMsg)
|
||||||
|
return result, fmt.Errorf("任务失败: %s", errMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(time.Duration(interval) * time.Second)
|
time.Sleep(time.Duration(interval) * time.Second)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user