diff --git a/client/create.go b/client/create.go index 06b90e7..e60d9fe 100755 --- a/client/create.go +++ b/client/create.go @@ -40,7 +40,14 @@ func (client *Client) SendEmail(request *EmailRequest) (*EmailCreateResponse, er if resp.StatusCode >= http.StatusBadRequest { response, err := readResponseBody[Response[ErrorResponse]](resp) if err != nil { - return nil, err + bodyContents := make([]byte, resp.ContentLength) + _, err := resp.Body.Read(bodyContents) + + if err != nil { + return nil, errors.New("Failed to read error response body: " + err.Error()) + } + + return nil, errors.New("An error occurred while sending the email: " + resp.Status + " - " + string(bodyContents)) } if response.Payload.Message == "" {