Display better error message

This commit is contained in:
Anthony Laibe 2018-10-28 17:10:38 +01:00
parent 1576db38d5
commit 360df5f6ef
2 changed files with 6 additions and 3 deletions

View File

@ -161,8 +161,8 @@ class ContractFunction extends Component {
<ListGroup>
{this.props.contractFunctions.map(contractFunction => (
<ListGroupItem key={contractFunction.result}>
{contractFunction.inputs.length > 0 && <p>Inputs: {contractFunction.inputs.join(', ')}</p>}
<strong>Result: {contractFunction.result}</strong>
{contractFunction.inputs.length > 0 && <p>Input(s): {contractFunction.inputs.join(', ')}</p>}
<strong>Result: {JSON.stringify(contractFunction.result)}</strong>
</ListGroupItem>
))}
</ListGroup>

View File

@ -116,7 +116,7 @@ class ContractsManager {
self.events.request("blockchain:contract:create", {abi: contract.abiDefinition, address: contract.deployedAddress}, async (contractObj) => {
try {
const gas = await contractObj.methods[req.body.method].apply(this, req.body.inputs).estimateGas();
contractObj.methods[req.body.method].apply(this, req.body.inputs)[funcCall]({from: account, gasPrice: req.body.gasPrice, gas}, (error, result) => {
contractObj.methods[req.body.method].apply(this, req.body.inputs)[funcCall]({from: account, gasPrice: req.body.gasPrice, gas: Math.floor(gas)}, (error, result) => {
if (error) {
return res.send({result: error.message});
}
@ -124,6 +124,9 @@ class ContractsManager {
res.send({result});
});
} catch (e) {
if (funcCall === 'call' && e.message === 'Returned error: gas required exceeds allowance or always failing transaction') {
return res.send({result: 'Failing call, this could be because of invalid inputs or function guards that may have been triggered, or an unknown error.'});
}
res.send({result: e.message});
}
});