From 9e2502651961f3f9b05f649e07eca17b8e46600a Mon Sep 17 00:00:00 2001 From: John <33443230+gazzua@users.noreply.github.com> Date: Sat, 17 Aug 2024 05:18:16 +0900 Subject: [PATCH] Fix error handling to use os.IsNotExist (#14315) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Radosław Kapka --- validator/accounts/wallet/wallet.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/validator/accounts/wallet/wallet.go b/validator/accounts/wallet/wallet.go index 1ebcab12d48c..8dd3f853cb5f 100644 --- a/validator/accounts/wallet/wallet.go +++ b/validator/accounts/wallet/wallet.go @@ -119,9 +119,7 @@ func IsValid(walletDir string) (bool, error) { } f, err := os.Open(expanded) // #nosec G304 if err != nil { - if strings.Contains(err.Error(), "no such file") || - strings.Contains(err.Error(), "cannot find the file") || - strings.Contains(err.Error(), "cannot find the path") { + if os.IsNotExist(err) { return false, nil } return false, err