Errors refactoring.

This commit is contained in:
Alexey Skobkin 2016-03-30 04:51:42 +03:00
parent 287d95055a
commit b8fea1a30f
1 changed files with 9 additions and 2 deletions

View File

@ -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