Skip to content

Commit

Permalink
Changing returned errtypes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Fearne committed Aug 11, 2022
1 parent b06e1d7 commit a0a43c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
3 changes: 1 addition & 2 deletions pkg/storage/fs/cback/cback.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,7 @@ func (fs *cback) Download(ctx context.Context, ref *provider.Reference) (io.Read

}

err = errors.New("not found")
return nil, err
return nil, errtypes.NotFound("cback: resource not found")
}

func (fs *cback) GetHome(ctx context.Context) (string, error) {
Expand Down
13 changes: 5 additions & 8 deletions pkg/storage/fs/cback/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"time"

provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/cs3org/reva/pkg/errtypes"
)

type backUpResponse struct {
Expand Down Expand Up @@ -110,18 +111,15 @@ func (fs *cback) getRequest(userName, url string, reqType string) (io.ReadCloser
}

if resp.StatusCode == 404 {
err = errors.New("not found")
return nil, err
return nil, errtypes.NotFound("cback: resource not found")
}

if resp.StatusCode == 500 {
err = errors.New("invalid query")
return nil, err
return nil, errtypes.InternalError("cback: internal server error")
}

if resp.StatusCode == 403 {
err = errors.New("no permissions to get backup")
return nil, err
return nil, errtypes.PermissionDenied("cback: user has no permissions to get the backup")
}

return resp.Body, nil
Expand Down Expand Up @@ -317,8 +315,7 @@ func (fs *cback) pathFinder(userName, path string) ([]string, error) {
return returnString, nil
}

err = errors.New("no match found")
return nil, err
return nil, errtypes.NotFound("cback: resource not found")

}

Expand Down

0 comments on commit a0a43c6

Please sign in to comment.