mirror of
https://bitbucket.org/skobkin/point-tools-go.git
synced 2024-11-22 04:46:03 +00:00
Errors refactoring.
This commit is contained in:
parent
287d95055a
commit
b8fea1a30f
11
client.go
11
client.go
|
@ -8,6 +8,13 @@ import (
|
|||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"errors"
|
||||
)
|
||||
|
||||
// Package errors
|
||||
var (
|
||||
ErrHttpRequest = errors.New("point-api: HTTP request error")
|
||||
ErrJsonDeserialization = errors.New("point-api: JSON deserialization error")
|
||||
)
|
||||
|
||||
type PointToolsClient struct {
|
||||
|
@ -53,13 +60,13 @@ func (c *PointToolsClient) SendPage(page point.Page) (ReceiveAllPageResponse, er
|
|||
body, reqErr := c.client.MakePostRequest(c.apiUrl+"all/page", data, nil)
|
||||
|
||||
if reqErr != nil {
|
||||
return response, reqErr
|
||||
return response, ErrHttpRequest
|
||||
}
|
||||
|
||||
jsonErr := json.Unmarshal(body, &response)
|
||||
|
||||
if jsonErr != nil {
|
||||
return response, jsonErr
|
||||
return response, ErrJsonDeserialization
|
||||
}
|
||||
|
||||
return response, nil
|
||||
|
|
Loading…
Reference in a new issue