|
|
@@ -2,6 +2,7 @@ package state
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
+ "errors"
|
|
|
"fmt"
|
|
|
resty "github.com/go-resty/resty/v2"
|
|
|
"strconv"
|
|
|
@@ -50,7 +51,7 @@ func (api *API) SaveState(storeName string, request []SaveStateRequest) error {
|
|
|
}
|
|
|
|
|
|
if resp.IsError() {
|
|
|
- return fmt.Errorf("Status %d: %s\n", resp.StatusCode(), resp.Body())
|
|
|
+ return errors.New(string(resp.Body()))
|
|
|
}
|
|
|
|
|
|
return nil
|
|
|
@@ -67,7 +68,7 @@ func (api *API) GetState(storeName string, key string, queryParams map[string]st
|
|
|
}
|
|
|
|
|
|
if resp.IsError() {
|
|
|
- return "", "", fmt.Errorf("Status %d: %s\n", resp.StatusCode(), resp.Body())
|
|
|
+ return "", "", errors.New(string(resp.Body()))
|
|
|
}
|
|
|
|
|
|
var body string
|
|
|
@@ -96,7 +97,7 @@ func (api *API) GetStateBulk(storeName string, queryParams map[string]string, re
|
|
|
}
|
|
|
|
|
|
if resp.IsError() {
|
|
|
- return nil, fmt.Errorf("Status %d: %s\n", resp.StatusCode(), resp.Body())
|
|
|
+ return nil, errors.New(string(resp.Body()))
|
|
|
}
|
|
|
|
|
|
items := make([]GetStateBulkItem, 0)
|
|
|
@@ -121,7 +122,7 @@ func (api *API) DeleteState(storeName string, key string, queryParams map[string
|
|
|
}
|
|
|
|
|
|
if resp.IsError() {
|
|
|
- return fmt.Errorf("Status %d: %s\n", resp.StatusCode(), resp.Body())
|
|
|
+ return errors.New(string(resp.Body()))
|
|
|
}
|
|
|
|
|
|
return nil
|
|
|
@@ -139,7 +140,7 @@ func (api *API) Transaction(storeName string, request TransactionRequest) error
|
|
|
}
|
|
|
|
|
|
if resp.IsError() {
|
|
|
- return fmt.Errorf("Status %d: %s\n", resp.StatusCode(), resp.Body())
|
|
|
+ return errors.New(string(resp.Body()))
|
|
|
}
|
|
|
|
|
|
return nil
|