Fix error handling to use os.IsNotExist (#14315)

Co-authored-by: Radosław Kapka <rkapka@wp.pl>
This commit is contained in:
John
2024-08-17 05:18:16 +09:00
committed by GitHub
parent 9e9559df60
commit 9e25026519

View File

@@ -119,9 +119,7 @@ func IsValid(walletDir string) (bool, error) {
} }
f, err := os.Open(expanded) // #nosec G304 f, err := os.Open(expanded) // #nosec G304
if err != nil { if err != nil {
if strings.Contains(err.Error(), "no such file") || if os.IsNotExist(err) {
strings.Contains(err.Error(), "cannot find the file") ||
strings.Contains(err.Error(), "cannot find the path") {
return false, nil return false, nil
} }
return false, err return false, err