refactor: enhance error handling in client creation and context management
All checks were successful
🚀 Publish Release Package / publish (push) Successful in 21s

This commit is contained in:
2025-06-25 12:30:29 -04:00
parent ac789c1cba
commit 95bb27698b
2 changed files with 21 additions and 12 deletions

View File

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