Error Handling on Contract Calls to Other Contracts

by Eric Falkenstein   Last Updated October 18, 2019 04:28 AM

I'm trying to call a function from another contract and need a way to accommodate errors.

Say contract A has the method getBalance:

function getBalance(address x) public view returns(uint output) { output = Balance(x);}

I'd like to call this function and treat a null response as a zero. Currently, I can't get my function to simply revert, in that if I call addressA.getBalance(x), and x or addressA is misspecified, the function reverts and does not allow me to simply assume it is zero. I'd like it to find something like 'try:' in python for solidity.

Tags : solidity


Related Questions


Updated October 09, 2018 12:28 PM

Updated November 28, 2018 04:28 AM

Updated December 12, 2018 08:28 AM

Updated January 10, 2019 23:28 PM

Updated July 23, 2018 00:28 AM