Merge pull request #182 from status-im/bugfix/better-error-message
Display better error message
This commit is contained in:
commit
1dd5ae7831
|
@ -161,8 +161,8 @@ class ContractFunction extends Component {
|
||||||
<ListGroup>
|
<ListGroup>
|
||||||
{this.props.contractFunctions.map(contractFunction => (
|
{this.props.contractFunctions.map(contractFunction => (
|
||||||
<ListGroupItem key={contractFunction.result}>
|
<ListGroupItem key={contractFunction.result}>
|
||||||
{contractFunction.inputs.length > 0 && <p>Inputs: {contractFunction.inputs.join(', ')}</p>}
|
{contractFunction.inputs.length > 0 && <p>Input(s): {contractFunction.inputs.join(', ')}</p>}
|
||||||
<strong>Result: {contractFunction.result}</strong>
|
<strong>Result: {JSON.stringify(contractFunction.result)}</strong>
|
||||||
</ListGroupItem>
|
</ListGroupItem>
|
||||||
))}
|
))}
|
||||||
</ListGroup>
|
</ListGroup>
|
||||||
|
|
|
@ -116,7 +116,7 @@ class ContractsManager {
|
||||||
self.events.request("blockchain:contract:create", {abi: contract.abiDefinition, address: contract.deployedAddress}, async (contractObj) => {
|
self.events.request("blockchain:contract:create", {abi: contract.abiDefinition, address: contract.deployedAddress}, async (contractObj) => {
|
||||||
try {
|
try {
|
||||||
const gas = await contractObj.methods[req.body.method].apply(this, req.body.inputs).estimateGas();
|
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) {
|
if (error) {
|
||||||
return res.send({result: error.message});
|
return res.send({result: error.message});
|
||||||
}
|
}
|
||||||
|
@ -124,6 +124,9 @@ class ContractsManager {
|
||||||
res.send({result});
|
res.send({result});
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} 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});
|
res.send({result: e.message});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue