Merge pull request #3798 from greatroar/errors

all: Move away from pkg/errors, easy cases
This commit is contained in:
MichaelEischer
2022-06-17 19:01:40 +02:00
committed by GitHub
23 changed files with 66 additions and 80 deletions
+1 -1
View File
@@ -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
}
+1 -1
View File
@@ -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
}
+2 -2
View File
@@ -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
View File
@@ -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)