From 6f5b0f3622dd52bbbe5acd932dd60b22ee0fce8c Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Wed, 8 Aug 2018 16:49:36 -0600 Subject: [PATCH] stat: Improve error message for bad snapshot ID (fixes #1933) --- cmd/restic/cmd_stats.go | 4 ++-- internal/restic/backend_find.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/restic/cmd_stats.go b/cmd/restic/cmd_stats.go index 970ee1291..3e0c6f348 100644 --- a/cmd/restic/cmd_stats.go +++ b/cmd/restic/cmd_stats.go @@ -100,13 +100,13 @@ func runStats(gopts GlobalOptions, args []string) error { } else { sID, err = restic.FindSnapshot(repo, snapshotIDString) if err != nil { - return err + Exitf(1, "error loading snapshot: %v", err) } } snapshot, err := restic.LoadSnapshot(ctx, repo, sID) if err != nil { - return err + Exitf(1, "error loading snapshot from repo: %v", err) } err = statsWalkSnapshot(ctx, snapshot, repo, stats) diff --git a/internal/restic/backend_find.go b/internal/restic/backend_find.go index 722a42dd2..4d11739e8 100644 --- a/internal/restic/backend_find.go +++ b/internal/restic/backend_find.go @@ -8,7 +8,7 @@ import ( // ErrNoIDPrefixFound is returned by Find() when no ID for the given prefix // could be found. -var ErrNoIDPrefixFound = errors.New("no ID found") +var ErrNoIDPrefixFound = errors.New("no matching ID found") // ErrMultipleIDMatches is returned by Find() when multiple IDs with the given // prefix are found.