UnUniFi / chain

GNU General Public License v3.0
35 stars 14 forks source link

show decent repay msg error message when nothing is borrowed #291

Closed taiki1frsh closed 1 year ago

taiki1frsh commented 1 year ago

~~when the borrowable amount is 0, the MsgBorrow will return null pointer. provide a decent error message.~~

when the borrowing amount is 0, the MsgRepay will return invalid error message.

taiki1frsh commented 1 year ago

@mkXultra In general, the 'tx' object in error message is 'null' like the other all msgs. Could you explain what the problem of it was for you?

mkXultra commented 1 year ago

Appropriate error messages are not in responce row_log. The message in row_log shows the go error message

taiki1frsh commented 1 year ago

I know. And actually this msg has appropriate error log, isn't? In the case which listing doesn't have any bid, which means borrowable amount is 0, I get this error raw_log:

 0uguu is smaller than 1uguu: insufficient funds
taiki1frsh commented 1 year ago

error state:

recovered: runtime error: invalid memory address or nil pointer dereference\nstack:\ngoroutine 174 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:24 +0x68\ngithub.com/cosmos/cosmos-sdk/baseapp.newDefaultRecoveryMiddleware.func1({0x102bcffa0, 0x103d2fc70})\n\tgithub.com/cosmos/cosmos-sdk@v0.46.0/baseapp/recovery.go:71 +0x28\ngithub.com/cosmos/cosmos-sdk/baseapp.newRecoveryMiddleware.func1({0x102bcffa0?, 0x103d2fc70?})\n\tgithub.com/cosmos/cosmos-sdk@v0.46.0/baseapp/recovery.go:39 +0x38\ngithub.com/cosmos/cosmos-sdk/baseapp.processRecovery({0x102bcffa0, 0x103d2fc70}, 0x14000580198?)\n\tgithub.com/cosmos/cosmos-sdk@v0.46.0/baseapp/recovery.go:28 +0x3c\ngithub.com/cosmos/cosmos-sdk/baseapp.processRecovery({0x102bcffa0, 0x103d2fc70}, 0x102e7a2e0?)\n\tgithub.com/cosmos/cosmos-sdk@v0.46.0/baseapp/recovery.go:33 +0x64\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTx.func1()\n\tgithub.com/cosmos/cosmos-sdk@v0.46.0/baseapp/baseapp.go:605 +0xac\npanic({0x102bcffa0, 0x103d2fc70})\n\truntime/panic.go:838 +0x204\nmath/big.(*Int).Cmp(0x102e7cb48?, 0x14001213cc0?)\n\tmath/big/int.go:328 +0x30\ncosmossdk.io/math.gt(...)\n\tcosmossdk.io/math@v1.0.0-beta.2/int.go:20\ncosmossdk.io/math.Int.GT(...)\n\tcosmossdk.io/math@v1.0.0-beta.2/int.go:209\ngithub.com/UnUniFi/chain/x/nftmarket/keeper.Keeper.Repay({{0x102e7cb48, 0x14001213cc0}, {0x102e77198, 0x140011fcec0}, {0x102e56db8, 0x140012e2580}, {0x102e56db8, 0x0}, {{0x12b7639c0, 0x14001213cc0}, ...}, ...}, ...)\n\tgithub.com/UnUniFi/chain/x/nftmarket/keeper/loan.go:122 +0x394\ngithub.com/UnUniFi/chain/x/nftmarket/keeper.msgServer.Repay({{{0x102e7cb48, 0x14001213cc0}, {0x102e77198, 0x140011fcec0}, {0x102e56db8, 0x140012e2580}, {0x102e56db8, 0x0}, {{0x12b7639c0, 0x14001213cc0}, ...}, ...}}, ...)\n\tgithub.com/UnUniFi/chain/x/nftmarket/keeper/msg_server.go:118 +0x1e4\ngithub.com/UnUniFi/chain/x/nftmarket.NewHandler.func1({{0x102e6c740, 0x14000058098}, {0x102e7a2e0, 0x14003652bc0}, {{0xb, 0x0}, {0x14004fceaac, 0x4}, 0x18, {0x23a56590, ...}, ...}, ...}, ...)\n\tgithub.com/UnUniFi/chain/x/nftmarket/handler.go:49 +0x728\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runMsgs(_, {{0x102e6c740, 0x14000058098}, {0x102e7a2e0, 0x14003652bc0}, {{0xb, 0x0}, {0x14004fceaac, 0x4}, 0x18, ...}, ...}, ...)\n\tgithub.com/cosmos/cosmos-sdk@v0.46.0/baseapp/baseapp.go:761 +0x5b0\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTx(0x14000cc2c40, 0x3, {0x1400503a280, 0x135, 0x135})\n\tgithub.com/cosmos/cosmos-sdk@v0.46.0/baseapp/baseapp.go:691 +0x8c4\ngithub.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).DeliverTx(0x14000cc2c40, {{0x1400503a280?, 0x20?, 0xb?}})\n\tgithub.com/cosmos/cosmos-sdk@v0.46.0/baseapp/abci.go:292 +0xac\ngithub.com/tendermint/tendermint/abci/client.(*localClient).DeliverTxAsync(0x140012f2960, {{0x1400503a280?, 0x140012f2960?, 0x1400339e308?}})\n\tgithub.com/tendermint/tendermint@v0.34.20/abci/client/local_client.go:93 +0xf8\ngithub.com/tendermint/tendermint/proxy.(*appConnConsensus).DeliverTxAsync(0x140040b4580?, {{0x1400503a280?, 0x20?, 0xb?}})\n\tgithub.com/tendermint/tendermint@v0.34.20/proxy/app_conn.go:85 +0x30\ngithub.com/tendermint/tendermint/state.execBlockOnProxyApp({0x102e6d770?, 0x14000e346c0}, {0x102e73618, 0x14000f97380}, 0x14000178000, {0x102e79408, 0x14000f963e0}, 0x17?)\n\tgithub.com/tendermint/tendermint@v0.34.20/state/execution.go:320 +0x708\ngithub.com/tendermint/tendermint/state.(*BlockExecutor).ApplyBlock(_, {{{0xb, 0x0}, {0x140015db330, 0x8}}, {0x140015db338, 0x4}, 0x1, 0x17, {{0x140040fbd80, ...}, ...}, ...}, ...)\n\tgithub.com/tendermint/tendermint@v0.34.20/state/execution.go:140 +0xe8\ngithub.com/tendermint/tendermint/consensus.(*State).finalizeCommit(0x1400115a000, 0x18)\n\tgithub.com/tendermint/tendermint@v0.34.20/consensus/state.go:1655 +0x954\ngithub.com/tendermint/tendermint/consensus.(*State).tryFinalizeCommit(0x1400115a000, 0x18)\n\tgithub.com/tendermint/tendermint@v0.34.20/consensus/state.go:1564 +0x290\ngithub.com/tendermint/tendermint/consensus.(*State).enterCommit.func1()\n\tgithub.com/tendermint/tendermint@v0.34.20/consensus/state.go:1499 +0x94\ngithub.com/tendermint/tendermint/consensus.(*State).enterCommit(0x1400115a000, 0x18, 0x0)\n\tgithub.com/tendermint/tendermint@v0.34.20/consensus/state.go:1537 +0xbc0\ngithub.com/tendermint/tendermint/consensus.(*State).addVote(0x1400115a000, 0x14003648820, {0x0, 0x0})\n\tgithub.com/tendermint/tendermint@v0.34.20/consensus/state.go:2151 +0xaf8\ngithub.com/tendermint/tendermint/consensus.(*State).tryAddVote(0x1400115a000, 0x14003648820, {0x0?, 0x100b98444?})\n\tgithub.com/tendermint/tendermint@v0.34.20/consensus/state.go:1949 +0x2c\ngithub.com/tendermint/tendermint/consensus.(*State).handleMsg(0x1400115a000, {{0x102e510d8?, 0x14000594540?}, {0x0?, 0x0?}})\n\tgithub.com/tendermint/tendermint@v0.34.20/consensus/state.go:856 +0x3c0\ngithub.com/tendermint/tendermint/consensus.(*State).receiveRoutine(0x1400115a000, 0x0)\n\tgithub.com/tendermint/tendermint@v0.34.20/consensus/state.go:783 +0x374\ncreated by github.com/tendermint/tendermint/consensus.(*State).OnStart\n\tgithub.com/tendermint/tendermint@v0.34.20/consensus/state.go:379 +0xf4\n: panic",