@@ -57,6 +57,9 @@ func (c *Client) Teach(image io.Reader, id, name string) error {
5757 return err
5858 }
5959 defer resp .Body .Close ()
60+ if resp .StatusCode < 200 || resp .StatusCode >= 300 {
61+ return errors .New (resp .Status )
62+ }
6063 return c .parseResponse (resp .Body )
6164}
6265
@@ -88,11 +91,10 @@ func (c *Client) TeachURL(imageURL *url.URL, id, name string) error {
8891 return err
8992 }
9093 defer resp .Body .Close ()
91- err = c .parseResponse (resp .Body )
92- if err != nil {
93- return err
94+ if resp .StatusCode < 200 || resp .StatusCode >= 300 {
95+ return errors .New (resp .Status )
9496 }
95- return nil
97+ return c . parseResponse ( resp . Body )
9698}
9799
98100// TeachBase64 teaches facebox the face in the Base64 encoded image.
@@ -120,11 +122,10 @@ func (c *Client) TeachBase64(data, id, name string) error {
120122 return err
121123 }
122124 defer resp .Body .Close ()
123- err = c .parseResponse (resp .Body )
124- if err != nil {
125- return err
125+ if resp .StatusCode < 200 || resp .StatusCode >= 300 {
126+ return errors .New (resp .Status )
126127 }
127- return nil
128+ return c . parseResponse ( resp . Body )
128129}
129130
130131// Remove makes facebox to forget a face
@@ -153,11 +154,10 @@ func (c *Client) Remove(id string) error {
153154 return err
154155 }
155156 defer resp .Body .Close ()
156- err = c .parseResponse (resp .Body )
157- if err != nil {
158- return err
157+ if resp .StatusCode < 200 || resp .StatusCode >= 300 {
158+ return errors .New (resp .Status )
159159 }
160- return nil
160+ return c . parseResponse ( resp . Body )
161161}
162162
163163func (c * Client ) parseResponse (r io.Reader ) error {
0 commit comments