- FreeBatchStoreSkuInfo与FreeBatchStoreSkuSyncInfo添加任务名

This commit is contained in:
gazebo
2019-08-07 14:15:30 +08:00
parent cef5be3e06
commit 8768fe8236
7 changed files with 33 additions and 24 deletions

View File

@@ -3,6 +3,7 @@ package tasksch
import (
"encoding/json"
"fmt"
"strings"
"sync"
"time"
@@ -283,6 +284,14 @@ func (t *BaseTask) getResult() []interface{} {
return t.Result
}
func (t *BaseTask) AddBatchErr(err error) {
if err != nil {
t.locker.Lock()
defer t.locker.Unlock()
t.batchErrList = append(t.batchErrList, err)
}
}
// func (t *BaseTask) GetOriginalErr() error {
// t.locker.RLock()
// defer t.locker.RUnlock()
@@ -330,9 +339,11 @@ func (t *BaseTask) Error() (errMsg string) {
errMsg += "," + t.mainErr.Error()
} else {
errMsg += fmt.Sprintf("部分失败, 总共:%d, 成功:%d, 失败:%d, 详情如下:\n", t.TotalItemCount, t.FinishedItemCount, t.FailedItemCount)
for _, v := range t.batchErrList {
errMsg += fmt.Sprintf("%s,\n", v.Error())
strList := make([]string, len(t.batchErrList))
for k, v := range t.batchErrList {
strList[k] = v.Error()
}
errMsg += strings.Join(strList, ",\n")
}
t.locker.Lock()
t.Err = errMsg