Handle error response when reading a file.

This commit is contained in:
Olof-Joachim Frahm 2017-12-20 10:53:49 +01:00
parent e3cd1f98e7
commit a11466bd13

View File

@ -261,7 +261,12 @@ func (c *Client) ReadStream(path string) (io.ReadCloser, error) {
if err != nil {
return nil, newPathErrorErr("ReadStream", path, err)
}
if rs.StatusCode == 200 {
return rs.Body, nil
} else {
rs.Body.Close()
return nil, newPathError("ReadStream", path, rs.StatusCode)
}
}
func (c *Client) Write(path string, data []byte, _ os.FileMode) error {