diff --git a/pkg/common/constant/error.go b/pkg/common/constant/error.go index 26f9be6f5..af72a3961 100644 --- a/pkg/common/constant/error.go +++ b/pkg/common/constant/error.go @@ -62,6 +62,18 @@ var ( ErrTokenDifferentUserID = ErrInfo{TokenDifferentUserIDError, "TokenDifferentUserIDError", ""} ) +func NewErrNetwork(err error) error { + newErrNetwork := ErrNetwork + newErrNetwork.DetailErrMsg = err.Error() + return ErrNetwork +} + +func NewErrData(err error) error { + newErrData := ErrData + newErrData.DetailErrMsg = err.Error() + return ErrNetwork +} + func toDetail(err error, info ErrInfo) ErrInfo { errInfo := info errInfo.DetailErrMsg = err.Error() diff --git a/pkg/common/http/http_client.go b/pkg/common/http/http_client.go index 3c430a9ab..721ee627f 100644 --- a/pkg/common/http/http_client.go +++ b/pkg/common/http/http_client.go @@ -67,13 +67,13 @@ func CallBackPostReturn(url, callbackCommand string, input interface{}, output c if failedContinue != nil && *failedContinue { return constant.ErrCallbackContinue } - return constant.ErrNetwork + return constant.NewErrNetwork(err) } if err = json.Unmarshal(b, output); err != nil { if failedContinue != nil && *failedContinue { return constant.ErrCallbackContinue } - return constant.ErrData + return constant.NewErrData(err) } return output.Parse() }