Ethereum Wallet will show error message if transaction has error before send. How to do like that using rpc api.
You can call
eth_estimateGas, or with web3,
estimateGas(), to simulate what will happen when you run the transaction. This should return an error message if the transaction results in an error.
Be aware that the situation may change between calling
eth_estimateGas and your actual transaction being mined, so in some cases a transaction that ran without error may still error out when actually sent, or vice versa.