Skip to content

Commit

Permalink
use notFound error instead KeyNotFound error
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantani committed Nov 5, 2024
1 parent 9ebe876 commit 8ce8fad
Show file tree
Hide file tree
Showing 23 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ require (
github.com/gorilla/mux v1.8.1
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0
github.com/ignite/modules v0.0.3-0.20241024202353-6c96918b625d
github.com/ignite/modules v0.0.3-0.20241105050027-482388061bf0
github.com/pkg/errors v0.9.1
github.com/spf13/cast v1.6.0
github.com/spf13/cobra v1.8.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -927,8 +927,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w=
github.com/ianlancetaylor/demangle v0.0.0-20230524184225-eabc099b10ab/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw=
github.com/ignite/modules v0.0.3-0.20241024202353-6c96918b625d h1:ntYnHx8sxSF/y6qjni+JD0FrR8jedL7EMPWPXRkNCjw=
github.com/ignite/modules v0.0.3-0.20241024202353-6c96918b625d/go.mod h1:Rmv2KTn5jfXL/qkKdaHD4ExJ1eaH1iVQDs+YD4eTV+o=
github.com/ignite/modules v0.0.3-0.20241105050027-482388061bf0 h1:qvonR8WK2qH4Le87Y1qt6d6U2E4I09mCDE0BgCCfok4=
github.com/ignite/modules v0.0.3-0.20241105050027-482388061bf0/go.mod h1:Rmv2KTn5jfXL/qkKdaHD4ExJ1eaH1iVQDs+YD4eTV+o=
github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ=
github.com/improbable-eng/grpc-web v0.15.0/go.mod h1:1sy9HKV4Jt9aEs9JSnkWlRJPuPtwNr0l57L4f878wP8=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
Expand Down
2 changes: 1 addition & 1 deletion x/launch/keeper/query_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (q queryServer) GetChain(ctx context.Context, req *types.QueryGetChainReque
chain, err := q.k.Chain.Get(ctx, req.LaunchId)
if err != nil {
if errors.Is(err, collections.ErrNotFound) {
return nil, sdkerrors.ErrKeyNotFound
return nil, sdkerrors.ErrNotFound
}

return nil, status.Error(codes.Internal, "internal error")
Expand Down
4 changes: 2 additions & 2 deletions x/launch/keeper/query_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ func TestChainQuerySingle(t *testing.T) {
response: &types.QueryGetChainResponse{Chain: msgs[1]},
},
{
desc: "KeyNotFound",
desc: "NotFound",
request: &types.QueryGetChainRequest{LaunchId: uint64(len(msgs))},
err: sdkerrors.ErrKeyNotFound,
err: sdkerrors.ErrNotFound,
},
{
desc: "InvalidRequest",
Expand Down
2 changes: 1 addition & 1 deletion x/launch/keeper/query_genesis_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestGenesisAccountQuerySingle(t *testing.T) {
response: &types.QueryGetGenesisAccountResponse{GenesisAccount: msgs[1]},
},
{
desc: "KeyNotFound",
desc: "NotFound",
request: &types.QueryGetGenesisAccountRequest{
Address: sample.Address(r),
LaunchId: 100000,
Expand Down
2 changes: 1 addition & 1 deletion x/launch/keeper/query_genesis_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestGenesisValidatorQuerySingle(t *testing.T) {
response: &types.QueryGetGenesisValidatorResponse{GenesisValidator: msgs[1]},
},
{
desc: "KeyNotFound",
desc: "NotFound",
request: &types.QueryGetGenesisValidatorRequest{
Address: sample.Address(r),
LaunchId: 100000,
Expand Down
2 changes: 1 addition & 1 deletion x/launch/keeper/query_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (q queryServer) GetRequest(ctx context.Context, req *types.QueryGetRequestR
request, err := q.k.Request.Get(ctx, collections.Join(req.LaunchId, req.RequestId))
if err != nil {
if errors.Is(err, collections.ErrNotFound) {
return nil, sdkerrors.ErrKeyNotFound
return nil, sdkerrors.ErrNotFound
}

return nil, status.Error(codes.Internal, "internal error")
Expand Down
4 changes: 2 additions & 2 deletions x/launch/keeper/query_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ func TestRequestQuerySingle(t *testing.T) {
response: &types.QueryGetRequestResponse{Request: msgs[1]},
},
{
desc: "KeyNotFound",
desc: "NotFound",
request: &types.QueryGetRequestRequest{LaunchId: uint64(len(msgs)), RequestId: uint64(len(msgs))},
err: sdkerrors.ErrKeyNotFound,
err: sdkerrors.ErrNotFound,
},
{
desc: "InvalidRequest",
Expand Down
2 changes: 1 addition & 1 deletion x/launch/keeper/query_vesting_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestVestingAccountQuerySingle(t *testing.T) {
response: &types.QueryGetVestingAccountResponse{VestingAccount: msgs[1]},
},
{
desc: "KeyNotFound",
desc: "NotFound",
request: &types.QueryGetVestingAccountRequest{
Address: sample.Address(r),
LaunchId: 100000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestLaunchIDFromChannelIDQuerySingle(t *testing.T) {
response: &types.QueryGetLaunchIDFromChannelIDResponse{LaunchIdFromChannelId: msgs[1]},
},
{
desc: "KeyNotFound",
desc: "NotFound",
request: &types.QueryGetLaunchIDFromChannelIDRequest{
ChannelId: strconv.Itoa(100000),
},
Expand Down
2 changes: 1 addition & 1 deletion x/monitoringc/keeper/query_monitoring_history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestMonitoringHistoryQuerySingle(t *testing.T) {
response: &types.QueryGetMonitoringHistoryResponse{MonitoringHistory: msgs[1]},
},
{
desc: "KeyNotFound",
desc: "NotFound",
request: &types.QueryGetMonitoringHistoryRequest{
LaunchId: 100000,
},
Expand Down
2 changes: 1 addition & 1 deletion x/monitoringc/keeper/query_provider_client_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestProviderClientIDQuerySingle(t *testing.T) {
response: &types.QueryGetProviderClientIDResponse{ProviderClientId: msgs[1]},
},
{
desc: "KeyNotFound",
desc: "NotFound",
request: &types.QueryGetProviderClientIDRequest{
LaunchId: 100000,
},
Expand Down
2 changes: 1 addition & 1 deletion x/monitoringc/keeper/query_verified_client_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestVerifiedClientIDQuerySingle(t *testing.T) {
response: &types.QueryGetVerifiedClientIDResponse{VerifiedClientId: msgs[1]},
},
{
desc: "KeyNotFound",
desc: "NotFound",
request: &types.QueryGetVerifiedClientIDRequest{
LaunchId: 100000,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestAuctionUsedAllocationsQuerySingle(t *testing.T) {
response: &types.QueryGetAuctionUsedAllocationsResponse{AuctionUsedAllocations: msgs[1]},
},
{
desc: "KeyNotFound",
desc: "NotFound",
request: &types.QueryGetAuctionUsedAllocationsRequest{
AuctionId: 100,
Address: sample.Address(r),
Expand Down
2 changes: 1 addition & 1 deletion x/participation/keeper/query_used_allocations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestUsedAllocationsQuerySingle(t *testing.T) {
response: &types.QueryGetUsedAllocationsResponse{UsedAllocations: msgs[1]},
},
{
desc: "KeyNotFound",
desc: "NotFound",
request: &types.QueryGetUsedAllocationsRequest{
Address: strconv.Itoa(100000),
},
Expand Down
6 changes: 3 additions & 3 deletions x/profile/keeper/query_coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (q queryServer) GetCoordinator(ctx context.Context, req *types.QueryGetCoor
coordinator, err := q.k.Coordinator.Get(ctx, req.CoordinatorId)
if err != nil {
if errors.Is(err, collections.ErrNotFound) {
return nil, sdkerrors.ErrKeyNotFound
return nil, sdkerrors.ErrNotFound
}

return nil, status.Error(codes.Internal, "internal error")
Expand All @@ -63,7 +63,7 @@ func (q queryServer) GetCoordinatorByAddress(ctx context.Context, req *types.Que
coordinatorByAddress, err := q.k.CoordinatorByAddress.Get(ctx, address)
if err != nil {
if errors.Is(err, collections.ErrNotFound) {
return nil, sdkerrors.ErrKeyNotFound
return nil, sdkerrors.ErrNotFound
}

return nil, status.Error(codes.Internal, "internal error")
Expand All @@ -72,7 +72,7 @@ func (q queryServer) GetCoordinatorByAddress(ctx context.Context, req *types.Que
coordinator, err := q.k.Coordinator.Get(ctx, coordinatorByAddress.CoordinatorId)
if err != nil {
if errors.Is(err, collections.ErrNotFound) {
return nil, sdkerrors.ErrKeyNotFound
return nil, sdkerrors.ErrNotFound
}

return nil, status.Error(codes.Internal, "internal error")
Expand Down
6 changes: 3 additions & 3 deletions x/profile/keeper/query_coordinator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ func TestCoordinatorQuerySingle(t *testing.T) {
response: &types.QueryGetCoordinatorResponse{Coordinator: msgs[1]},
},
{
desc: "KeyNotFound",
desc: "NotFound",
request: &types.QueryGetCoordinatorRequest{CoordinatorId: uint64(len(msgs))},
err: sdkerrors.ErrKeyNotFound,
err: sdkerrors.ErrNotFound,
},
{
desc: "InvalidRequest",
Expand Down Expand Up @@ -172,7 +172,7 @@ func TestCoordinatorByAddressQuerySingle(t *testing.T) {
{
desc: "should prevent querying non existing coordinator by address",
request: &types.QueryGetCoordinatorByAddressRequest{Address: sample.Address(r)},
err: sdkerrors.ErrKeyNotFound,
err: sdkerrors.ErrNotFound,
},
{
desc: "should prevent querying invalid coordinator by address",
Expand Down
2 changes: 1 addition & 1 deletion x/profile/keeper/query_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestValidatorQuerySingle(t *testing.T) {
response: &types.QueryGetValidatorResponse{Validator: msgs[1]},
},
{
desc: "KeyNotFound",
desc: "NotFound",
request: &types.QueryGetValidatorRequest{
Address: strconv.Itoa(100000),
},
Expand Down
2 changes: 1 addition & 1 deletion x/project/keeper/query_mainnet_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestMainnetAccountQuerySingle(t *testing.T) {
response: &types.QueryGetMainnetAccountResponse{MainnetAccount: msgs[1]},
},
{
desc: "KeyNotFound",
desc: "NotFound",
request: &types.QueryGetMainnetAccountRequest{
Address: sample.Address(r),
ProjectId: 100000,
Expand Down
2 changes: 1 addition & 1 deletion x/project/keeper/query_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (q queryServer) GetProject(ctx context.Context, req *types.QueryGetProjectR
project, err := q.k.Project.Get(ctx, req.ProjectId)
if err != nil {
if errors.Is(err, collections.ErrNotFound) {
return nil, sdkerrors.ErrKeyNotFound
return nil, sdkerrors.ErrNotFound
}

return nil, status.Error(codes.Internal, "internal error")
Expand Down
2 changes: 1 addition & 1 deletion x/project/keeper/query_project_chains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestProjectChainsQuerySingle(t *testing.T) {
response: &types.QueryGetProjectChainsResponse{ProjectChains: msgs[1]},
},
{
desc: "KeyNotFound",
desc: "NotFound",
request: &types.QueryGetProjectChainsRequest{
ProjectId: 100000,
},
Expand Down
4 changes: 2 additions & 2 deletions x/project/keeper/query_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ func TestProjectQuerySingle(t *testing.T) {
response: &types.QueryGetProjectResponse{Project: msgs[1]},
},
{
desc: "KeyNotFound",
desc: "NotFound",
request: &types.QueryGetProjectRequest{ProjectId: uint64(len(msgs))},
err: sdkerrors.ErrKeyNotFound,
err: sdkerrors.ErrNotFound,
},
{
desc: "InvalidRequest",
Expand Down
2 changes: 1 addition & 1 deletion x/reward/keeper/query_reward_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestRewardPoolQuerySingle(t *testing.T) {
response: &types.QueryGetRewardPoolResponse{RewardPool: msgs[1]},
},
{
desc: "KeyNotFound",
desc: "NotFound",
request: &types.QueryGetRewardPoolRequest{
LaunchId: 100000,
},
Expand Down

0 comments on commit 8ce8fad

Please sign in to comment.