From 8f61392c083eea3ef7292c84617c684e4aa5d76e Mon Sep 17 00:00:00 2001 From: Bryan White Date: Wed, 15 Nov 2023 09:36:07 +0100 Subject: [PATCH] [Supplier] chore: improve supplier not found error message (#183) * chore: improve error message seen by RPC consumers when the given supplier isn't on-chain * fix: query supplier test * chore: add todo comment --- x/supplier/keeper/query_supplier.go | 5 ++++- x/supplier/keeper/query_supplier_test.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/x/supplier/keeper/query_supplier.go b/x/supplier/keeper/query_supplier.go index 14d5afab5..7f381104c 100644 --- a/x/supplier/keeper/query_supplier.go +++ b/x/supplier/keeper/query_supplier.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "fmt" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" @@ -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 diff --git a/x/supplier/keeper/query_supplier_test.go b/x/supplier/keeper/query_supplier_test.go index 6690e3f75..ad28a377b 100644 --- a/x/supplier/keeper/query_supplier_test.go +++ b/x/supplier/keeper/query_supplier_test.go @@ -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",