In solidity, is there any way to throw custom Exceptions
along with error messages? I am using throw
to prevent further execution of my code but this always results in invalid JUMP
(in geth console, on debugging) and Intrinsic gas too low
(in Mist).Can I have custom error messages?
For example can we modify transfer(..)
function to produce error message account balance is low
when balance of sender is less than amount he wants to transfer?
function transfer(address _to, uint256 _value) {
if (balanceOf[msg.sender] < _value) // Check if the sender has enough
{
throw;
// some code to display "account balance is low" to user instead of 'Intrinsic Gas too low'
}
balanceOf[msg.sender] -= _value; // Subtract from the sender
balanceOf[_to] += _value; // Add the same to the recipient
Transfer(msg.sender, _to, _value); // Notify anyone listening that this transfer took
}