Skip to content

Commit ba5dc6f

Browse files
authored
Merge pull request #284 from BaruchBilanski/SLK-88741-client-err-handling
bug(client): add error handling - request and events
2 parents 11e10b8 + ba34a19 commit ba5dc6f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

client/client.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,16 @@ func (cli *Client) GetUSEAuthToken() (string, string, error) {
184184
cli.token = data["token"].(string)
185185
//get the ese_url to make the API requests.
186186
request := cli.gorequest
187+
if request == nil {
188+
return "", "", fmt.Errorf("request is uninitialized")
189+
}
190+
187191
request.Set("Authorization", "Bearer "+cli.token)
188192
events, body, errs := request.Clone().Get(provUrl + "/v1/envs").End()
189-
190-
if errs != nil {
191-
log.Println(events.StatusCode)
193+
if errs != nil || events == nil {
194+
if events != nil {
195+
log.Println(events.StatusCode)
196+
}
192197
err := fmt.Errorf("error calling %s", provUrl)
193198
return "", "", err
194199
}

0 commit comments

Comments
 (0)