diff options
author | Frédéric Guillot <fred@miniflux.net> | 2018-05-21 12:24:48 -0700 |
---|---|---|
committer | Frédéric Guillot <fred@miniflux.net> | 2018-05-21 19:58:36 -0400 |
commit | fb49ad24d5418ee9b7f65e9c36f07a1717608fcb (patch) | |
tree | bc4efdab54442f36405ea069f89fde1accf1c349 /integration | |
parent | b270159aae97359afe02f3c4843fa0f4e9a1a1b6 (diff) |
Improve error handling in integration clients
Diffstat (limited to 'integration')
-rw-r--r-- | integration/instapaper/instapaper.go | 6 | ||||
-rw-r--r-- | integration/nunuxkeeper/nunuxkeeper.go | 6 | ||||
-rw-r--r-- | integration/pinboard/pinboard.go | 6 |
3 files changed, 15 insertions, 3 deletions
diff --git a/integration/instapaper/instapaper.go b/integration/instapaper/instapaper.go index ee44edd..3b9e91c 100644 --- a/integration/instapaper/instapaper.go +++ b/integration/instapaper/instapaper.go @@ -31,11 +31,15 @@ func (c *Client) AddURL(link, title string) error { clt := client.New(apiURL) clt.WithCredentials(c.username, c.password) response, err := clt.Get() + if err != nil { + return fmt.Errorf("instapaper: unable to send url: %v", err) + } + if response.HasServerFailure() { return fmt.Errorf("instapaper: unable to send url, status=%d", response.StatusCode) } - return err + return nil } // NewClient returns a new Instapaper client. diff --git a/integration/nunuxkeeper/nunuxkeeper.go b/integration/nunuxkeeper/nunuxkeeper.go index cb340ab..76367e1 100644 --- a/integration/nunuxkeeper/nunuxkeeper.go +++ b/integration/nunuxkeeper/nunuxkeeper.go @@ -47,11 +47,15 @@ func (c *Client) AddEntry(link, title, content string) error { clt := client.New(apiURL) clt.WithCredentials("api", c.apiKey) response, err := clt.PostJSON(doc) + if err != nil { + return fmt.Errorf("nunux-keeper: unable to send entry: %v", err) + } + if response.HasServerFailure() { return fmt.Errorf("nunux-keeper: unable to send entry, status=%d", response.StatusCode) } - return err + return nil } // NewClient returns a new Nunux Keeepr client. diff --git a/integration/pinboard/pinboard.go b/integration/pinboard/pinboard.go index d34e4fe..0de1dd2 100644 --- a/integration/pinboard/pinboard.go +++ b/integration/pinboard/pinboard.go @@ -36,11 +36,15 @@ func (c *Client) AddBookmark(link, title, tags string, markAsUnread bool) error clt := client.New("https://api.pinboard.in/v1/posts/add?" + values.Encode()) response, err := clt.Get() + if err != nil { + return fmt.Errorf("pinboard: unable to send bookmark: %v", err) + } + if response.HasServerFailure() { return fmt.Errorf("pinboard: unable to send bookmark, status=%d", response.StatusCode) } - return err + return nil } // NewClient returns a new Pinboard client. |