|
|
@@ -2,8 +2,8 @@ package state
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
- "errors"
|
|
|
"fmt"
|
|
|
+ "git.sxidc.com/service-supports/dapr_api/utils"
|
|
|
resty "github.com/go-resty/resty/v2"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
@@ -51,7 +51,7 @@ func (api *API) SaveState(storeName string, request []SaveStateRequest) error {
|
|
|
}
|
|
|
|
|
|
if resp.IsError() {
|
|
|
- return errors.New(string(resp.Body()))
|
|
|
+ return utils.ResponseStatusError(resp)
|
|
|
}
|
|
|
|
|
|
return nil
|
|
|
@@ -68,7 +68,7 @@ func (api *API) GetState(storeName string, key string, queryParams map[string]st
|
|
|
}
|
|
|
|
|
|
if resp.IsError() {
|
|
|
- return "", "", errors.New(string(resp.Body()))
|
|
|
+ return "", "", utils.ResponseStatusError(resp)
|
|
|
}
|
|
|
|
|
|
var body string
|
|
|
@@ -97,7 +97,7 @@ func (api *API) GetStateBulk(storeName string, queryParams map[string]string, re
|
|
|
}
|
|
|
|
|
|
if resp.IsError() {
|
|
|
- return nil, errors.New(string(resp.Body()))
|
|
|
+ return nil, utils.ResponseStatusError(resp)
|
|
|
}
|
|
|
|
|
|
items := make([]GetStateBulkItem, 0)
|
|
|
@@ -122,7 +122,7 @@ func (api *API) DeleteState(storeName string, key string, queryParams map[string
|
|
|
}
|
|
|
|
|
|
if resp.IsError() {
|
|
|
- return errors.New(string(resp.Body()))
|
|
|
+ return utils.ResponseStatusError(resp)
|
|
|
}
|
|
|
|
|
|
return nil
|
|
|
@@ -140,7 +140,7 @@ func (api *API) Transaction(storeName string, request TransactionRequest) error
|
|
|
}
|
|
|
|
|
|
if resp.IsError() {
|
|
|
- return errors.New(string(resp.Body()))
|
|
|
+ return utils.ResponseStatusError(resp)
|
|
|
}
|
|
|
|
|
|
return nil
|