- refactor RebuildError
- output store and sku info when mtwm api failed
This commit is contained in:
@@ -3,6 +3,7 @@ package platformapi
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
@@ -173,3 +174,20 @@ func AccessPlatformAPIWithRetry(client *http.Client, handleRequest func() *http.
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func RebuildError(inErr error, bzParams map[string]interface{}, watchKeys []string) (outErr error) {
|
||||
if inErr != nil {
|
||||
if codeErr, ok := inErr.(*utils.ErrorWithCode); ok {
|
||||
appendErrList := []string{}
|
||||
for _, key := range watchKeys {
|
||||
if bzParams[key] != nil {
|
||||
appendErrList = append(appendErrList, fmt.Sprintf("[%s:%v]", key, bzParams[key]))
|
||||
}
|
||||
}
|
||||
if len(appendErrList) > 0 {
|
||||
inErr = utils.NewErrorCode(strings.Join(appendErrList, ",")+", "+codeErr.ErrMsg(), codeErr.Code())
|
||||
}
|
||||
}
|
||||
}
|
||||
return inErr
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user