Suppose, we have an election contract that selects a candidate, based on highest votes, among a set of candidates. This contract can be expected to check if a voter tries to vote more than once.
An implementation of such a check should ideally respond with an error message should the check fail. In the API development world, a JSON message for the error encountered would be the way to go. However, if the same approach was used for a contract, I would imagine that, a fair share of expense would be on building and returning that JSON object.
Another option could be to return a simple JSON object in case of success as {'r' : '0x00', 'resp' : { ... } }
and failure as {'r' :
0x01}
. A wrapper around a web3.js
implementation could translate the 0x01
into something more verbose.
Other thoughts?