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 {
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 == "" {

View file

@ -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")
}

View file

@ -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{