mirror of
https://github.com/restic/restic.git
synced 2026-08-28 16:27:31 +00:00
Merge pull request #3798 from greatroar/errors
all: Move away from pkg/errors, easy cases
This commit is contained in:
@@ -144,7 +144,7 @@ func init() {
|
||||
func filterExisting(items []string) (result []string, err error) {
|
||||
for _, item := range items {
|
||||
_, err := fs.Lstat(item)
|
||||
if err != nil && os.IsNotExist(errors.Cause(err)) {
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
Warnf("%v does not exist, skipping\n", item)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ func runMount(opts MountOptions, gopts GlobalOptions, args []string) error {
|
||||
|
||||
mountpoint := args[0]
|
||||
|
||||
if _, err := resticfs.Stat(mountpoint); os.IsNotExist(errors.Cause(err)) {
|
||||
if _, err := resticfs.Stat(mountpoint); errors.Is(err, os.ErrNotExist) {
|
||||
Verbosef("Mountpoint %s doesn't exist\n", mountpoint)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ func resolvePassword(opts GlobalOptions, envStr string) (string, error) {
|
||||
}
|
||||
if opts.PasswordFile != "" {
|
||||
s, err := textfile.Read(opts.PasswordFile)
|
||||
if os.IsNotExist(errors.Cause(err)) {
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
return "", errors.Fatalf("%s does not exist", opts.PasswordFile)
|
||||
}
|
||||
return strings.TrimSpace(string(s)), errors.Wrap(err, "Readfile")
|
||||
@@ -398,7 +398,7 @@ func ReadRepo(opts GlobalOptions) (string, error) {
|
||||
}
|
||||
|
||||
s, err := textfile.Read(opts.RepositoryFile)
|
||||
if os.IsNotExist(errors.Cause(err)) {
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
return "", errors.Fatalf("%s does not exist", opts.RepositoryFile)
|
||||
}
|
||||
if err != nil {
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ func main() {
|
||||
err := cmdRoot.Execute()
|
||||
|
||||
switch {
|
||||
case restic.IsAlreadyLocked(errors.Cause(err)):
|
||||
case restic.IsAlreadyLocked(err):
|
||||
fmt.Fprintf(os.Stderr, "%v\nthe `unlock` command can be used to remove stale locks\n", err)
|
||||
case err == ErrInvalidSourceData:
|
||||
fmt.Fprintf(os.Stderr, "Warning: %v\n", err)
|
||||
|
||||
Reference in New Issue
Block a user