chore: rename errors

This commit is contained in:
Noah Hsu
2022-06-23 16:03:27 +08:00
parent fd5c3e831d
commit d77dea733f
7 changed files with 21 additions and 24 deletions

View File

@ -86,7 +86,7 @@ func Get(ctx context.Context, account driver.Driver, path string) (model.Obj, er
return f, nil
}
}
return nil, errors.WithStack(errs.ErrorObjectNotFound)
return nil, errors.WithStack(errs.ObjectNotFound)
}
var linkCache = cache.NewMemCache(cache.WithShards[*model.Link](16))
@ -104,7 +104,7 @@ func Link(ctx context.Context, account driver.Driver, path string, args model.Li
return nil, errors.WithMessage(err, "failed to get file")
}
if file.IsDir() {
return nil, errors.New("file is dir")
return nil, errors.WithStack(errs.NotFile)
}
link, err := account.Link(ctx, file, args)
if err != nil {
@ -123,7 +123,7 @@ func MakeDir(ctx context.Context, account driver.Driver, path string) error {
// check if dir exists
f, err := Get(ctx, account, path)
if err != nil {
if errs.IsErrObjectNotFound(err) {
if errs.IsObjectNotFound(err) {
parentPath, dirName := stdpath.Split(path)
err = MakeDir(ctx, account, parentPath)
if err != nil {
@ -183,7 +183,7 @@ func Remove(ctx context.Context, account driver.Driver, path string) error {
obj, err := Get(ctx, account, path)
if err != nil {
// if object not found, it's ok
if errs.IsErrObjectNotFound(err) {
if errs.IsObjectNotFound(err) {
return nil
}
return errors.WithMessage(err, "failed to get object")