Reputation: 83536
I am writing a set of interacting smart contracts for a NEAR blockchain. Let's imagine the the following scenario
Unlike a single shard Ethereum, NEAR does cross contract calls with promises. Whereas a single tripped require()
automatically rolls back to the whole Ethereum transactions, in the sharded nature to NEAR smart contracts themselves are responsible for rolling back state changes if the promise they triggered does not complete successfully.
My question is how to safely handle failures in the chain of promises between NEAR smart contracts
try {} catch {}
in JavaScript await/async modelUpvotes: 2
Views: 359
Reputation: 1154
Generally you can only tell whether a promise has succeeded without knowing what goes wrong in the case of an error. An example of such a check can be found here https://github.com/near/core-contracts/blob/4f245101d7d029ffb3450c560770db244fc7b3ce/lockup/src/utils.rs#L7. What is the use case of reacting differently to different error that you have in mind?
Upvotes: 3