- refactor RebuildError

- output store and sku info when mtwm api failed
This commit is contained in:
gazebo
2019-03-17 21:41:45 +08:00
parent 1cec54c840
commit 26f1d37caf
4 changed files with 38 additions and 43 deletions

View File

@@ -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
}