multiversx/mx-sdk-rs

Query's errors not handled

Opened this issue · 0 comments

gfusee commented

When a query is a success from the HTTP's point of view (code 200), but a failure regarding the smart contract (code != 0), the sdk panics. This is not a wanted behavior since we cannot handle the errors easily, the only way to do so is by unwinding the stack which is a bad practice.

This error happens because the CommunicationProxy's execute_vmquery method try to parse the result to a ResponseVmValue, regardless if the query is a success or not.

To reproduce:

Query any smart contract with a random function to have the "invalid function" error

(I will likely do a PR soon to fix this)