Skip to content

Commit 7917236

Browse files
committed
Fix example
1 parent fc46c85 commit 7917236

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

.idea/vcs.xml

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ if err != nil {
108108
fmt.Printf("Fetched %d messages.\n", len(messages))
109109

110110
// Deleting a specific message
111-
_, err = client.DeleteMessageV1(context.Background(), messages[0].ID)
111+
_, err = client.DeleteMessage(context.Background(), messages[0].ID)
112112
if err != nil {
113113
// handle error
114114
}

client.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ func (c *Client) do(req *http.Request, v interface{}) (*Response, error) {
6262
defer r.Body.Close()
6363

6464
if r.StatusCode < 200 || r.StatusCode >= 300 {
65-
var httpErr HTTPError
65+
httpErr := HTTPError{
66+
Response: r,
67+
}
6668
if err := json.NewDecoder(r.Body).Decode(&httpErr); err != nil {
6769
return nil, err
6870
}

error.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ type HTTPErrorMeta struct {
2929
}
3030

3131
func (h *HTTPError) Error() string {
32-
return fmt.Sprintf("status %d, error: %s, code: %s, detail: %s", h.Response.StatusCode, h.ErrorDetails.Type, h.ErrorDetails.Code, h.ErrorDetails.Detail)
32+
return fmt.Sprintf("status %d, error type: %s, code: %s, detail: %s", h.Response.StatusCode, h.ErrorDetails.Type, h.ErrorDetails.Code, h.ErrorDetails.Detail)
3333
}
3434

3535
func (h *HTTPError) fullError() string {
36-
return fmt.Sprintf("status %d, error: %s, code: %s, detail: %s, request_id: %s", h.Response.StatusCode, h.ErrorDetails.Type, h.ErrorDetails.Code, h.ErrorDetails.Detail, h.Meta.RequestID)
36+
return fmt.Sprintf("status %d, error type: %s, code: %s, detail: %s, request_id: %s", h.Response.StatusCode, h.ErrorDetails.Type, h.ErrorDetails.Code, h.ErrorDetails.Detail, h.Meta.RequestID)
3737
}
3838

3939
// Format implements fmt.Formatter interface.

0 commit comments

Comments
 (0)