We're trying to figure out whether to use return
or throw
in Solidity when a condition fails and we don't assume user maliciousness. Here's the pros and cons we've figured so far:
Why use throw
- Any side effects of the code are reverted
- Some wallets may predict
throw
ahead of time, warning the user
Why use return
- Less gas is consumed by the unsuspecting user (again, assuming not a malicious call).
- A calling contract may gracefully recover from the failure, unlike with
throw
.
Are there any other considerations (or best-practices) we should be aware of?