Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error loggin when a message execution fails #60

Closed
Kayanski opened this issue Sep 13, 2023 · 8 comments · Fixed by #63
Closed

Better error loggin when a message execution fails #60

Kayanski opened this issue Sep 13, 2023 · 8 comments · Fixed by #63
Assignees

Comments

@Kayanski
Copy link

The 3 lines here : https://github.com/CosmWasm/cw-multi-test/blob/main/src/wasm.rs#L210-L213, prevent error messages to propagate properly (especially for nested execution and replies to error messages).

This makes it really difficult to find out what the error message is.

I understand that this mimic Contract execution and obscure error messages, but for dev purposes, is it possible to propagate errors without obfuscating them ?

Thank you for your concern :)

@DariuszDepta
Copy link
Member

Hi @Kayanski,

There is a chain of errors returned, that can be simply printed in debug, e.g.:

println!("{:?}", err);

and produces full error report with the initial place where the error occured, similar to following:

Error executing WasmMsg:
sender: random
Execute { contract_addr: "contract0", msg: {"execute":{"contract_addr":"contract1","msg":"eyJleGVjdXRlIjp7ImNvbnRyYWN0X2FkZHIiOiJjb250cmFjdDIiLCJtc2ciOiJlMzA9IiwiZnVuZHMiOltdfX0=","funds":[]}}, funds: [] }

Caused by:
    0: error executing WasmMsg:
       sender: contract0
       Execute { contract_addr: "contract1", msg: {"execute":{"contract_addr":"contract2","msg":"e30=","funds":[]}}, funds: [] }
    1: error executing WasmMsg:
       sender: contract1
       Execute { contract_addr: "contract2", msg: {}, funds: [] }
    2: Generic error: Handle failed

You can check it in the App test, here:
https://github.com/CosmWasm/cw-multi-test/blob/main/src/app.rs#L3210-L3211

Let me know if it addresses your needs :-)

@Kayanski
Copy link
Author

Kayanski commented Sep 13, 2023

Hello, thanks for the quick reply !

Actually, what I am doing in my contract is returning the error that gets sent in a reply as text to an acknowlegment function (for IBC purposes) so what's returned is only the error Display text and not Debug, and I don't have access to that error. Because it's IBC obviously the function should not error.

For now, I'm just commenting out the lines I quoted above for my needs, but as per your answer, I don't see a way of handling that better for now.

@DariuszDepta
Copy link
Member

DariuszDepta commented Sep 13, 2023

Ok, so if the Display for such an error would contain the report I mentioned previously, then it would be then satisfactory for you?

@Kayanski
Copy link
Author

Yes that would be very good for my purposes ! Thank you. IBC is always complicated to handle, let's make it simple 🦾

@DariuszDepta
Copy link
Member

Just to make it clearer for me, could you provide only the code snippet where you get the error and you convert it to text to place it in reply message, please?

@Kayanski
Copy link
Author

@DariuszDepta
Copy link
Member

Hello @Kayanski!

Could you run your tests using Multi Test from the branch better-error-logging, just to verify if it reports your errors more precisely?

Thanks in advance.

@Kayanski
Copy link
Author

Hello ! This is perfect ! I now have something like this, which is expected and simpler to debug :

{"fatal_error":"Error executing WasmMsg:\n  sender: contract9\n  Execute { contract_addr: \"contract9\", msg: {\"rx\":{\"connection_id\":\"connection-0\",\"counterparty_port\":\"wasm.contract8\",\"data\":\"eyJzZW5kZXIiOiJjb250cmFjdDQiLCJtc2ciOnsiZXhlY3V0ZSI6eyJtc2dzIjpbXX19fQ==\"}}, funds: [] }\n\nCaused by:\n    Generic error: Invalid input: canonical address length not correct"}

Thank you for this fix !

@DariuszDepta DariuszDepta self-assigned this Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants