You've already forked email-api-client
refactor: enhance error handling in client creation and context management
All checks were successful
🚀 Publish Release Package / publish (push) Successful in 21s
All checks were successful
🚀 Publish Release Package / publish (push) Successful in 21s
This commit is contained in:
@@ -3,6 +3,7 @@ package client
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"gitea.siteworxpro.com/golang-packages/email-api-client/redis"
|
||||
"net/http"
|
||||
"time"
|
||||
@@ -47,6 +48,10 @@ func getToken(configuration *Configuration) (*Token, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK || resp.ContentLength <= 0 {
|
||||
return nil, errors.New("Failed to retrieve access token: " + resp.Status)
|
||||
}
|
||||
|
||||
responseBody := make([]byte, resp.ContentLength)
|
||||
_, err = resp.Body.Read(responseBody)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user