mirror of
https://github.com/usememos/memos.git
synced 2025-10-26 22:36:16 +08:00
fix: remove errors.Wrap(nil) (#4576)
* Fix errors.Wrap(nil) * fix resource_test failure where resource does not exist
This commit is contained in:
parent
88b38ff2c0
commit
d649d326ef
5 changed files with 6 additions and 6 deletions
|
|
@ -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")
|
return nil, errors.Wrap(err, "failed to get inbox")
|
||||||
}
|
}
|
||||||
if len(list) != 1 {
|
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
|
return list[0], nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ func (d *DB) CreateUser(ctx context.Context, create *store.User) (*store.User, e
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(list) != 1 {
|
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
|
return list[0], nil
|
||||||
|
|
@ -142,7 +142,7 @@ func (d *DB) GetUser(ctx context.Context, find *store.FindUser) (*store.User, er
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(list) != 1 {
|
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
|
return list[0], nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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")
|
return nil, errors.Wrap(err, "failed to get inbox")
|
||||||
}
|
}
|
||||||
if len(list) != 1 {
|
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
|
return list[0], nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ func (s *Store) DeleteResource(ctx context.Context, delete *DeleteResource) erro
|
||||||
return errors.Wrap(err, "failed to get resource")
|
return errors.Wrap(err, "failed to get resource")
|
||||||
}
|
}
|
||||||
if resource == nil {
|
if resource == nil {
|
||||||
return errors.Wrap(nil, "resource not found")
|
return errors.New("resource not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
if resource.StorageType == storepb.ResourceStorageType_LOCAL {
|
if resource.StorageType == storepb.ResourceStorageType_LOCAL {
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,6 @@ func TestResourceStore(t *testing.T) {
|
||||||
err = ts.DeleteResource(ctx, &store.DeleteResource{
|
err = ts.DeleteResource(ctx, &store.DeleteResource{
|
||||||
ID: 2,
|
ID: 2,
|
||||||
})
|
})
|
||||||
require.NoError(t, err)
|
require.ErrorContains(t, err, "resource not found")
|
||||||
ts.Close()
|
ts.Close()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue