Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

fix: remove errors.Wrap(nil) (#4576)

cmuangsd649d326ef5e
diff --git a/store/db/mysql/inbox.go b/store/db/mysql/inbox.go
index 5932f46d3..a18fb51f1 100644
--- a/store/db/mysql/inbox.go
+++ b/store/db/mysql/inbox.go
@@ -110,7 +110,7 @@ func (d *DB) GetInbox(ctx context.Context, find *store.FindInbox) (*store.Inbox,
return nil, errors.Wrap(err, "failed to get inbox")
}
if len(list) != 1 {
- return nil, errors.Wrapf(nil, "unexpected inbox count: %d", len(list))
+ return nil, errors.Errorf("unexpected inbox count: %d", len(list))
}
return list[0], nil
}
diff --git a/store/db/mysql/user.go b/store/db/mysql/user.go
index 9bf2d9640..fab15066a 100644
--- a/store/db/mysql/user.go
+++ b/store/db/mysql/user.go
@@ -32,7 +32,7 @@ func (d *DB) CreateUser(ctx context.Context, create *store.User) (*store.User, e
return nil, err
}
if len(list) != 1 {
- return nil, errors.Wrapf(nil, "unexpected user count: %d", len(list))
+ return nil, errors.Errorf("unexpected user count: %d", len(list))
}
return list[0], nil
@@ -142,7 +142,7 @@ func (d *DB) GetUser(ctx context.Context, find *store.FindUser) (*store.User, er
return nil, err
}
if len(list) != 1 {
- return nil, errors.Wrapf(nil, "unexpected user count: %d", len(list))
+ return nil, errors.Errorf("unexpected user count: %d", len(list))
}
return list[0], nil
}
diff --git a/store/db/postgres/inbox.go b/store/db/postgres/inbox.go
index 81a80427b..1777d801d 100644
--- a/store/db/postgres/inbox.go
+++ b/store/db/postgres/inbox.go
@@ -100,7 +100,7 @@ func (d *DB) GetInbox(ctx context.Context, find *store.FindInbox) (*store.Inbox,
return nil, errors.Wrap(err, "failed to get inbox")
}
if len(list) != 1 {
- return nil, errors.Wrapf(nil, "unexpected inbox count: %d", len(list))
+ return nil, errors.Errorf("unexpected inbox count: %d", len(list))
}
return list[0], nil
}
diff --git a/store/resource.go b/store/resource.go
index 71aec1db7..fdb68d47f 100644
--- a/store/resource.go
+++ b/store/resource.go
@@ -103,7 +103,7 @@ func (s *Store) DeleteResource(ctx context.Context, delete *DeleteResource) erro
return errors.Wrap(err, "failed to get resource")
}
if resource == nil {
- return errors.Wrap(nil, "resource not found")
+ return errors.New("resource not found")
}
if resource.StorageType == storepb.ResourceStorageType_LOCAL {
diff --git a/store/test/resource_test.go b/store/test/resource_test.go
index 663e9d8ad..dcf6751bf 100644
--- a/store/test/resource_test.go
+++ b/store/test/resource_test.go
@@ -58,6 +58,6 @@ func TestResourceStore(t *testing.T) {
err = ts.DeleteResource(ctx, &store.DeleteResource{
ID: 2,
})
- require.NoError(t, err)
+ require.ErrorContains(t, err, "resource not found")
ts.Close()
}