From 92316a98534ea2b7b7e77c5ecf38544dd6fa46a8 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sat, 6 Jan 2018 22:44:18 +0100 Subject: [PATCH 1/2] restore: Improve error message for more than one ID --- cmd/restic/cmd_restore.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/restic/cmd_restore.go b/cmd/restic/cmd_restore.go index 11eb13a23..2ffb4cda8 100644 --- a/cmd/restic/cmd_restore.go +++ b/cmd/restic/cmd_restore.go @@ -53,8 +53,11 @@ func init() { func runRestore(opts RestoreOptions, gopts GlobalOptions, args []string) error { ctx := gopts.ctx - if len(args) != 1 { + switch { + case len(args) == 0: return errors.Fatal("no snapshot ID specified") + case len(args) > 1: + return errors.Fatalf("more than one snapshot ID specified: %v", args) } if opts.Target == "" { From 032621289bf8444f80c183357245e255d483e79e Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sat, 6 Jan 2018 23:11:54 +0100 Subject: [PATCH 2/2] errors: Add "Fatal" prefix for Fatalf() --- internal/errors/fatal.go | 2 +- internal/options/options_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/errors/fatal.go b/internal/errors/fatal.go index b61822c00..02ffdaab4 100644 --- a/internal/errors/fatal.go +++ b/internal/errors/fatal.go @@ -34,5 +34,5 @@ func Fatal(s string) error { // Fatalf returns an error which implements the Fataler interface. func Fatalf(s string, data ...interface{}) error { - return fatalError(fmt.Sprintf(s, data...)) + return Wrap(fatalError(fmt.Sprintf(s, data...)), "Fatal") } diff --git a/internal/options/options_test.go b/internal/options/options_test.go index ecdd918aa..de94fc90a 100644 --- a/internal/options/options_test.go +++ b/internal/options/options_test.go @@ -65,11 +65,11 @@ var invalidOptsTests = []struct { }{ { []string{"=bar", "bar=baz", "k="}, - "empty key is not a valid option", + "Fatal: empty key is not a valid option", }, { []string{"x=1", "foo=bar", "y=2", "foo=baz"}, - `key "foo" present more than once`, + `Fatal: key "foo" present more than once`, }, } @@ -185,7 +185,7 @@ var invalidSetTests = []struct { "first_name": "foobar", }, "ns", - "option ns.first_name is not known", + "Fatal: option ns.first_name is not known", }, { Options{