mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02: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:
@@ -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()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user