Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
Replace status.Error to errorsmod and sdkerrors
Browse files Browse the repository at this point in the history
  • Loading branch information
foxytanuki committed Nov 17, 2023
1 parent 2a69cc1 commit 62ac294
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions x/registry/keeper/query_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ 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"
)

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)
Expand All @@ -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
Expand Down

0 comments on commit 62ac294

Please sign in to comment.