1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-22 15:57:07 +00:00

backup: Improve error message for invalid pattern

This commit is contained in:
Alexander Neumann 2018-10-03 11:12:51 +02:00
parent 33dfbf5c38
commit fb31d66951
2 changed files with 6 additions and 1 deletions

View file

@ -4,6 +4,7 @@ import (
"bufio" "bufio"
"bytes" "bytes"
"context" "context"
"fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
@ -308,7 +309,7 @@ func collectTargets(opts BackupOptions, args []string) (targets []string, err er
var expanded []string var expanded []string
expanded, err := filepath.Glob(line) expanded, err := filepath.Glob(line)
if err != nil { if err != nil {
return nil, err return nil, errors.WithMessage(err, fmt.Sprintf("pattern: %s", line))
} }
lines = append(lines, expanded...) lines = append(lines, expanded...)
} }

View file

@ -22,6 +22,10 @@ var Wrap = errors.Wrap
// nil, Wrapf returns nil. // nil, Wrapf returns nil.
var Wrapf = errors.Wrapf 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, // Cause returns the cause of an error. It will also unwrap certain errors,
// e.g. *url.Error returned by the net/http client. // e.g. *url.Error returned by the net/http client.
func Cause(err error) error { func Cause(err error) error {