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 d9a2739
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 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
8 changes: 4 additions & 4 deletions x/registry/keeper/query_role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"strconv"
"time"

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/testutil"
"github.com/mycel-domain/mycel/x/registry/keeper"
Expand Down Expand Up @@ -125,11 +125,11 @@ func (suite *KeeperTestSuite) TestRole() {
DomainName: "notexist",
Address: creator,
},
err: status.Error(codes.NotFound, "domain not found"),
err: errorsmod.Wrapf(sdkerrors.ErrNotFound, "domain not found"),
},
{
desc: "InvalidRequest",
err: status.Error(codes.InvalidArgument, "invalid request"),
err: errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "invalid request: empty request"),
},
}

Expand Down

0 comments on commit d9a2739

Please sign in to comment.