diff --git a/cmd/restic/cmd_backup.go b/cmd/restic/cmd_backup.go index c435682bc..c82ba8ff4 100644 --- a/cmd/restic/cmd_backup.go +++ b/cmd/restic/cmd_backup.go @@ -457,7 +457,7 @@ func collectTargets(opts BackupOptions, args []string) (targets []string, err er var expanded []string expanded, err := filepath.Glob(line) if err != nil { - return nil, errors.WithMessage(err, fmt.Sprintf("pattern: %s", line)) + return nil, fmt.Errorf("pattern: %s: %w", line, err) } if len(expanded) == 0 { Warnf("pattern %q does not match any files, skipping\n", line) diff --git a/cmd/restic/lock.go b/cmd/restic/lock.go index 851dcefe8..43bc22b4a 100644 --- a/cmd/restic/lock.go +++ b/cmd/restic/lock.go @@ -2,11 +2,11 @@ package main import ( "context" + "fmt" "sync" "time" "github.com/restic/restic/internal/debug" - "github.com/restic/restic/internal/errors" "github.com/restic/restic/internal/restic" ) @@ -45,7 +45,7 @@ func lockRepository(ctx context.Context, repo restic.Repository, exclusive bool) lock, err := lockFn(ctx, repo) if err != nil { - return nil, ctx, errors.WithMessage(err, "unable to create lock in backend") + return nil, ctx, fmt.Errorf("unable to create lock in backend: %w", err) } debug.Log("create lock %p (exclusive %v)", lock, exclusive) diff --git a/internal/errors/errors.go b/internal/errors/errors.go index 4fd94cbf2..0327ea0da 100644 --- a/internal/errors/errors.go +++ b/internal/errors/errors.go @@ -22,10 +22,6 @@ 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 - var WithStack = errors.WithStack // Go 1.13-style error handling.