From eb64a8f4bdb27085f19f6ae6a526983897fa2650 Mon Sep 17 00:00:00 2001 From: Christoph Polcin Date: Fri, 24 Oct 2014 11:38:11 +0200 Subject: [PATCH] uses newPathError --- client.go | 9 +++++---- utils.go | 5 ----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/client.go b/client.go index a811164..3562c0a 100644 --- a/client.go +++ b/client.go @@ -69,7 +69,6 @@ func getProps(r *response, status string) *props { } func (c *Client) ReadDir(path string) ([]os.FileInfo, error) { - // TODO return newPathError path = FixSlashes(path) files := make([]os.FileInfo, 0) skipSelf := true @@ -115,21 +114,23 @@ func (c *Client) ReadDir(path string) ([]os.FileInfo, error) { `, &response{}, parse) + if err != nil { + err = &os.PathError{"ReadDir", path, err} + } return files, err } func (c *Client) Remove(path string) error { - // TODO return newPathError rs, err := c.reqDo("DELETE", path, nil) if err != nil { - return err + return newPathError("Remove", path, 400) } defer rs.Body.Close() if rs.StatusCode == 200 { return nil } else { - return Error(rs) + return newPathError("Remove", path, rs.StatusCode) } } diff --git a/utils.go b/utils.go index febe5d7..fb21849 100644 --- a/utils.go +++ b/utils.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "net/http" "os" "strconv" "strings" @@ -17,10 +16,6 @@ func log(msg interface{}) { fmt.Println(msg) } -func Error(r *http.Response) error { - return errors.New(fmt.Sprintf("%s - %s %s", r.Status, r.Request.Method, r.Request.URL.String())) -} - func newPathError(op string, path string, statusCode int) error { return &os.PathError{op, path, errors.New(fmt.Sprintf("%d", statusCode))} }