Update error usage patterns to go1.13+ (#7529)

* rely on errors.Is

* wrap errors
This commit is contained in:
Victor Farazdagi
2020-10-14 20:39:52 +03:00
committed by GitHub
parent 8f04c555fc
commit a005c77b3f
25 changed files with 39 additions and 36 deletions

View File

@@ -133,7 +133,7 @@ func (s *Server) initializeWallet(ctx context.Context, cfg *wallet.Config) error
return wallet.ErrNoWalletFound
}
valid, err := wallet.IsValid(cfg.WalletDir)
if err == wallet.ErrNoWalletFound {
if errors.Is(err, wallet.ErrNoWalletFound) {
return wallet.ErrNoWalletFound
}
if err != nil {

View File

@@ -4,6 +4,7 @@ import (
"context"
"encoding/hex"
"encoding/json"
"errors"
"io/ioutil"
"path/filepath"
"strings"
@@ -183,7 +184,7 @@ func (s *Server) WalletConfig(ctx context.Context, _ *ptypes.Empty) (*pb.WalletR
return &pb.WalletResponse{}, nil
}
valid, err := wallet.IsValid(s.walletDir)
if err == wallet.ErrNoWalletFound {
if errors.Is(err, wallet.ErrNoWalletFound) {
return &pb.WalletResponse{}, nil
}
if err != nil {
@@ -255,7 +256,7 @@ func (s *Server) ChangePassword(ctx context.Context, req *pb.ChangePasswordReque
return nil, status.Errorf(codes.FailedPrecondition, noWalletMsg)
}
valid, err := wallet.IsValid(s.walletDir)
if err == wallet.ErrNoWalletFound {
if errors.Is(err, wallet.ErrNoWalletFound) {
return nil, status.Errorf(codes.FailedPrecondition, noWalletMsg)
}
if err != nil {