From 76f2c5a6321069b8ba879d935fe5d4195bb91930 Mon Sep 17 00:00:00 2001 From: Keepers Date: Thu, 22 Sep 2022 09:44:08 -0600 Subject: [PATCH] improve language on selector reduce error (#794) ## Description shorten and consolidate the error message when the provided selectors match zero entries in the backup entity list. ## Type of change - [x] :hamster: Trivial/Minor ## Issue(s) * #564 ## Test Plan - [x] :muscle: Manual - [ ] :zap: Unit test - [ ] :green_heart: E2E --- src/cli/backup/exchange.go | 2 +- src/internal/operations/restore.go | 2 +- src/pkg/selectors/selectors.go | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cli/backup/exchange.go b/src/cli/backup/exchange.go index 1d779b0ad..9640bae45 100644 --- a/src/cli/backup/exchange.go +++ b/src/cli/backup/exchange.go @@ -388,7 +388,7 @@ func detailsExchangeCmd(cmd *cobra.Command, args []string) error { ds := sel.Reduce(ctx, d) if len(ds.Entries) == 0 { - Info(ctx, "nothing to display: no items in the backup match the provided selectors") + Info(ctx, selectors.ErrorNoMatchingItems) return nil } diff --git a/src/internal/operations/restore.go b/src/internal/operations/restore.go index ff6bc8ccb..069d46448 100644 --- a/src/internal/operations/restore.go +++ b/src/internal/operations/restore.go @@ -134,7 +134,7 @@ func (op *RestoreOperation) Run(ctx context.Context) (err error) { // format the details and retrieve the items from kopia fds = er.Reduce(ctx, d) if len(fds.Entries) == 0 { - return errors.New("nothing to restore: no items in the backup match the provided selectors") + return selectors.ErrorNoMatchingItems } case selectors.ServiceOneDrive: diff --git a/src/pkg/selectors/selectors.go b/src/pkg/selectors/selectors.go index bc88608c8..88bca941f 100644 --- a/src/pkg/selectors/selectors.go +++ b/src/pkg/selectors/selectors.go @@ -21,7 +21,10 @@ const ( ServiceOneDrive // OneDrive ) -var ErrorBadSelectorCast = errors.New("wrong selector service type") +var ( + ErrorBadSelectorCast = errors.New("wrong selector service type") + ErrorNoMatchingItems = errors.New("no items match the specified selectors") +) const ( scopeKeyCategory = "category"