fix
This commit is contained in:
@@ -84,7 +84,7 @@ func (y *YushanService) CallAPI(ctx context.Context, code string, params map[str
|
||||
// 将请求数据转换为 JSON 字节数组
|
||||
messageBytes, err := json.Marshal(reqData)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("%w: %s", ErrSystem, err.Error())
|
||||
err = errors.Join(ErrSystem, err)
|
||||
if y.logger != nil {
|
||||
y.logger.LogError(requestID, transactionID, code, err, params)
|
||||
}
|
||||
@@ -94,7 +94,7 @@ func (y *YushanService) CallAPI(ctx context.Context, code string, params map[str
|
||||
// 获取 API 密钥
|
||||
key, err := hex.DecodeString(y.config.ApiKey)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("%w: %s", ErrSystem, err.Error())
|
||||
err = errors.Join(ErrSystem, err)
|
||||
if y.logger != nil {
|
||||
y.logger.LogError(requestID, transactionID, code, err, params)
|
||||
}
|
||||
@@ -113,7 +113,7 @@ func (y *YushanService) CallAPI(ctx context.Context, code string, params map[str
|
||||
}
|
||||
req, err := http.NewRequestWithContext(ctx, "POST", y.config.URL, strings.NewReader(content))
|
||||
if err != nil {
|
||||
err = fmt.Errorf("%w: %s", ErrSystem, err.Error())
|
||||
err = errors.Join(ErrSystem, err)
|
||||
if y.logger != nil {
|
||||
y.logger.LogError(requestID, transactionID, code, err, params)
|
||||
}
|
||||
@@ -125,7 +125,7 @@ func (y *YushanService) CallAPI(ctx context.Context, code string, params map[str
|
||||
// 执行请求
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("%w: %s", ErrSystem, err.Error())
|
||||
err = errors.Join(ErrSystem, err)
|
||||
if y.logger != nil {
|
||||
y.logger.LogError(requestID, transactionID, code, err, params)
|
||||
}
|
||||
@@ -149,7 +149,7 @@ func (y *YushanService) CallAPI(ctx context.Context, code string, params map[str
|
||||
} else {
|
||||
sDec, err := base64.StdEncoding.DecodeString(string(body))
|
||||
if err != nil {
|
||||
err = fmt.Errorf("%w: %s", ErrSystem, err.Error())
|
||||
err = errors.Join(ErrSystem, err)
|
||||
if y.logger != nil {
|
||||
y.logger.LogError(requestID, transactionID, code, err, params)
|
||||
}
|
||||
@@ -172,7 +172,7 @@ func (y *YushanService) CallAPI(ctx context.Context, code string, params map[str
|
||||
// retcode 为 000000,表示有数据,返回 retdata
|
||||
retData := gjson.GetBytes(respData, "retdata")
|
||||
if !retData.Exists() {
|
||||
err = fmt.Errorf("%w: %s", ErrDatasource, "羽山请求retdata为空")
|
||||
err = errors.Join(ErrDatasource, fmt.Errorf("羽山请求retdata为空"))
|
||||
if y.logger != nil {
|
||||
y.logger.LogError(requestID, transactionID, code, err, params)
|
||||
}
|
||||
@@ -180,7 +180,7 @@ func (y *YushanService) CallAPI(ctx context.Context, code string, params map[str
|
||||
}
|
||||
return []byte(retData.Raw), nil
|
||||
} else {
|
||||
err = fmt.Errorf("%w: %s", ErrDatasource, "羽山请求未知的状态码")
|
||||
err = errors.Join(ErrDatasource, fmt.Errorf("羽山请求未知的状态码"))
|
||||
if y.logger != nil {
|
||||
y.logger.LogError(requestID, transactionID, code, err, params)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user