Error Handling on Contract Calls to Other Contracts

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

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


How to map an address with a string array in solidity?

Updated October 09, 2018 12:28 PM

How to handle dynamic size string array in solidity?

Updated November 28, 2018 04:28 AM

What is the status of forbidden call in constructor?

Updated December 12, 2018 08:28 AM

How can I pass struct from one contract to another?

Updated January 10, 2019 23:28 PM

How to transfer Ether to ERC20 token contract?

Updated July 23, 2018 00:28 AM