Handle not found error for getBondsByIds and whois queries
All checks were successful
Build / build (pull_request) Successful in 2m42s
Integration Tests / test-integration (pull_request) Successful in 2m43s
E2E Tests / test-e2e (pull_request) Successful in 3m45s
Unit Tests / test-unit (pull_request) Successful in 2m13s
Lint / Run golangci-lint (pull_request) Successful in 5m4s

This commit is contained in:
neeraj 2024-03-12 11:53:00 +05:30
parent 67cbbf7088
commit 8944b50e0b

View File

@ -4,6 +4,7 @@ import (
"context"
"encoding/base64"
"strconv"
"strings"
"github.com/cosmos/cosmos-sdk/client"
types "github.com/cosmos/cosmos-sdk/types"
@ -41,6 +42,11 @@ func (q queryResolver) LookupAuthorities(ctx context.Context, names []string) ([
for _, name := range names {
res, err := nsQueryClient.Whois(context.Background(), &registrytypes.QueryWhoisRequest{Name: name})
if err != nil {
if strings.Contains(err.Error(), "Name authority not found") {
gqlResponse = append(gqlResponse, nil)
continue
}
return nil, err
}
@ -263,6 +269,10 @@ func (q *queryResolver) GetBond(ctx context.Context, id string) (*Bond, error) {
bondQueryClient := bondtypes.NewQueryClient(q.ctx)
bondResp, err := bondQueryClient.GetBondById(context.Background(), &bondtypes.QueryGetBondByIdRequest{Id: id})
if err != nil {
if strings.Contains(err.Error(), "Bond not found") {
return nil, nil
}
return nil, err
}