2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-25 22:27:35 +00:00

Merge pull request #1534 from restic/improve-error-restore

restore: Improve error message for more than one ID
This commit is contained in:
Alexander Neumann 2018-01-07 09:40:06 +01:00
commit 489eef5a6f
3 changed files with 8 additions and 5 deletions

View File

@ -53,8 +53,11 @@ func init() {
func runRestore(opts RestoreOptions, gopts GlobalOptions, args []string) error { func runRestore(opts RestoreOptions, gopts GlobalOptions, args []string) error {
ctx := gopts.ctx ctx := gopts.ctx
if len(args) != 1 { switch {
case len(args) == 0:
return errors.Fatal("no snapshot ID specified") 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 == "" { if opts.Target == "" {

View File

@ -34,5 +34,5 @@ func Fatal(s string) error {
// Fatalf returns an error which implements the Fataler interface. // Fatalf returns an error which implements the Fataler interface.
func Fatalf(s string, data ...interface{}) error { func Fatalf(s string, data ...interface{}) error {
return fatalError(fmt.Sprintf(s, data...)) return Wrap(fatalError(fmt.Sprintf(s, data...)), "Fatal")
} }

View File

@ -65,11 +65,11 @@ var invalidOptsTests = []struct {
}{ }{
{ {
[]string{"=bar", "bar=baz", "k="}, []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"}, []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", "first_name": "foobar",
}, },
"ns", "ns",
"option ns.first_name is not known", "Fatal: option ns.first_name is not known",
}, },
{ {
Options{ Options{