-
Notifications
You must be signed in to change notification settings - Fork 142
Open
Description
Hi, I am wondering if these two errors are supposed to be considered equivalent? I notice they are documented the same, and obviously have the same error message.
At my workplace we were just caught out by an index.ErrNotFound error in the following code:
// ListCustomers returns a slice of Customers.
func ListCustomers(ctx context.Context, tx storm.Node) ([]Customer, error) {
var c []Customer
err := tx.AllByIndex("Username", &c)
if errors.Is(err, storm.ErrNotFound) { // note: errors.Is() does not match index.ErrNotFound
return c, nil
}
return c, err
}I was just hoping for some guidance as to whether I should be handling both errors explicitly.
Thanks π
/cc @cwx-iggy
PS: If these errors are supposed to be equivalent, but have been duplicated to avoid a cyclic package dependency, perhaps the construction via errors.New() could be moved into an internal package and referenced from both the storm and index packages?
Metadata
Metadata
Assignees
Labels
No labels