diff --git a/cmd/restic/cmd_backup.go b/cmd/restic/cmd_backup.go index 5c4e1b563..a8de4bd4f 100644 --- a/cmd/restic/cmd_backup.go +++ b/cmd/restic/cmd_backup.go @@ -4,6 +4,7 @@ import ( "bufio" "bytes" "context" + "fmt" "io/ioutil" "os" "path/filepath" @@ -308,7 +309,7 @@ func collectTargets(opts BackupOptions, args []string) (targets []string, err er var expanded []string expanded, err := filepath.Glob(line) if err != nil { - return nil, err + return nil, errors.WithMessage(err, fmt.Sprintf("pattern: %s", line)) } lines = append(lines, expanded...) } diff --git a/internal/errors/errors.go b/internal/errors/errors.go index aa2ff6f2b..ffd3d615e 100644 --- a/internal/errors/errors.go +++ b/internal/errors/errors.go @@ -22,6 +22,10 @@ var Wrap = errors.Wrap // nil, Wrapf returns nil. var Wrapf = errors.Wrapf +// WithMessage annotates err with a new message. If err is nil, WithMessage +// returns nil. +var WithMessage = errors.WithMessage + // Cause returns the cause of an error. It will also unwrap certain errors, // e.g. *url.Error returned by the net/http client. func Cause(err error) error {