In the current version of the Plutus starter repo (commit a85818 which uses plutus-1.0.9), it seems difficult to know where to handle errors. For example, using the Game contract after initialization and wallets are created in accordance with the README, if you supply data that is the incorrect type to the guess endpoint (for example) all subsequent attempts to interact with the contract fail.
Steps to reproduce:
- Follow README up to line 177 (Successful wrong guess)
- No errors in status of contract instance
- Retry last curl with any JSON data that is not the object expected (e.g.):
curl -H "Content-Type: application/json" --data '"duck"' \
http://localhost:9080/api/contract/instance/$INSTANCE_ID/endpoint/guess
No interactions on this instance will work any longer (non-recoverable).
I have tried adding a handleError with a lambda function to output the error (which it does, logging a WalletError). It states that the last logMessage was waiting for triggering an endpoint, but the general state of the contract has an err status. Is there a general way to catch errors, output them, and then restore the state of the contract instance?