chore: minor fixes
This commit is contained in:
parent
0448f66ab2
commit
2af9e734dd
6 changed files with 28 additions and 15 deletions
|
|
@ -61,16 +61,16 @@ func (c *Client) Call(host string, path string, data any, out any) error {
|
|||
return fmt.Errorf("http %d: %s", httpResponse.StatusCode, string(b))
|
||||
}
|
||||
|
||||
var resp web.Response[json.RawMessage]
|
||||
if err := json.NewDecoder(httpResponse.Body).Decode(&resp); err != nil {
|
||||
return fmt.Errorf("decode response wrapper: %w", err)
|
||||
}
|
||||
|
||||
if !resp.Ok {
|
||||
return fmt.Errorf("error on the remote: %w", errors.New(resp.Err))
|
||||
}
|
||||
|
||||
if out != nil {
|
||||
var resp web.Response[json.RawMessage]
|
||||
if err := json.NewDecoder(httpResponse.Body).Decode(&resp); err != nil {
|
||||
return fmt.Errorf("decode response wrapper: %w", err)
|
||||
}
|
||||
|
||||
if !resp.Ok {
|
||||
return fmt.Errorf("error on the remote: %w", errors.New(resp.Err))
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(resp.Data, out); err != nil {
|
||||
return fmt.Errorf("decode response body: %w", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue