Errors refactoring.

This commit is contained in:
Alexey Skobkin 2016-03-30 04:51:42 +03:00
parent 287d95055a
commit b8fea1a30f

View file

@ -8,6 +8,13 @@ import (
"log" "log"
"net/http" "net/http"
"net/url" "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 { 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) body, reqErr := c.client.MakePostRequest(c.apiUrl+"all/page", data, nil)
if reqErr != nil { if reqErr != nil {
return response, reqErr return response, ErrHttpRequest
} }
jsonErr := json.Unmarshal(body, &response) jsonErr := json.Unmarshal(body, &response)
if jsonErr != nil { if jsonErr != nil {
return response, jsonErr return response, ErrJsonDeserialization
} }
return response, nil return response, nil