Skip to content

Commit

Permalink
[Supplier] chore: improve supplier not found error message (#183)
Browse files Browse the repository at this point in the history
* chore: improve error message seen by RPC consumers when the given supplier isn't on-chain

* fix: query supplier test

* chore: add todo comment
  • Loading branch information
bryanchriswhite authored Nov 15, 2023
1 parent 16c6ebc commit 8f61392
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion x/supplier/keeper/query_supplier.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"context"
"fmt"

"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -52,7 +53,9 @@ func (k Keeper) Supplier(goCtx context.Context, req *types.QueryGetSupplierReque
req.Address,
)
if !found {
return nil, status.Error(codes.NotFound, "not found")
// TODO_TECHDEBT(#181): conform to logging conventions once established
msg := fmt.Sprintf("supplier with address %q", req.GetAddress())
return nil, status.Error(codes.NotFound, msg)
}

return &types.QueryGetSupplierResponse{Supplier: val}, nil
Expand Down
2 changes: 1 addition & 1 deletion x/supplier/keeper/query_supplier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestSupplierQuerySingle(t *testing.T) {
request: &types.QueryGetSupplierRequest{
Address: strconv.Itoa(100000),
},
err: status.Error(codes.NotFound, "not found"),
err: status.Error(codes.NotFound, "supplier with address \"100000\""),
},
{
desc: "InvalidRequest",
Expand Down

0 comments on commit 8f61392

Please sign in to comment.