diff --git a/client.go b/client.go index 48e1a8e..5f82834 100644 --- a/client.go +++ b/client.go @@ -51,10 +51,14 @@ func New(config *config.Config) (*Client, error) { "Accept": "*/*"}) client.httpClient = httpClient - resp := client.auth() + resp, err := client.auth() + if err != nil { + client.logger.Error("error while executing auth request", "request", "auth", "error", err.Error()) + return nil, errors.New("error while executing auth request: " + err.Error()) + } var sd SessionData - err := json.Unmarshal(resp.Data, &sd) + err = json.Unmarshal(resp.Data, &sd) if err != nil { client.logger.Error("error while parsing json", "request", "auth", "error", err.Error()) } @@ -275,7 +279,7 @@ func (c *Client) execute(method string, url string, params map[string]string, j } // auth . -func (c *Client) auth() *Response { +func (c *Client) auth() (*Response, error) { params := map[string]string{ "env": "cloudprod", "deviceType": "android", @@ -290,10 +294,10 @@ func (c *Client) auth() *Response { c.logger.Debug("AUTH HTTP OUTPUT", "body", resp) if err != nil { c.logger.Error("error while executing auth request", "request", "auth", "error", err.Error()) - return nil + return nil, errors.New("error while executing auth request: " + err.Error()) } c.logger.Debug("AUTH HTTP OUTPUT", "body", resp) - return resp + return resp, nil } // parseResponse .