From 62ac294bc9c2089e801f9abcfcece65e9dc84382 Mon Sep 17 00:00:00 2001 From: foxytanuki Date: Sat, 18 Nov 2023 07:33:20 +0900 Subject: [PATCH] Replace status.Error to errorsmod and sdkerrors --- x/registry/keeper/query_role.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/x/registry/keeper/query_role.go b/x/registry/keeper/query_role.go index 3d5ded68..e60cbad8 100644 --- a/x/registry/keeper/query_role.go +++ b/x/registry/keeper/query_role.go @@ -4,9 +4,9 @@ import ( "context" "strings" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/mycel-domain/mycel/x/registry/types" ) @@ -14,7 +14,7 @@ import ( func (k Keeper) Role(goCtx context.Context, req *types.QueryRoleRequest) (*types.QueryRoleResponse, error) { var role types.DomainRole if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") + return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "invalid request: empty request") } ctx := sdk.UnwrapSDKContext(goCtx) @@ -24,17 +24,17 @@ func (k Keeper) Role(goCtx context.Context, req *types.QueryRoleRequest) (*types case 1: // TLD tld, found := k.GetTopLevelDomain(ctx, dms[0]) if !found { - return nil, status.Error(codes.NotFound, "domain not found") + return nil, errorsmod.Wrapf(sdkerrors.ErrNotFound, "domain not found") } role = tld.AccessControl[req.Address] case 2: // SLD sld, found := k.GetSecondLevelDomain(ctx, dms[0], dms[1]) if !found { - return nil, status.Error(codes.NotFound, "domain not found") + return nil, errorsmod.Wrapf(sdkerrors.ErrNotFound, "domain not found") } role = sld.AccessControl[req.Address] default: - return nil, status.Error(codes.InvalidArgument, "invalid request: domain name") + return nil, errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "invalid request: domain name") } return &types.QueryRoleResponse{Role: role.String()}, nil