mirror of https://github.com/embarklabs/embark.git
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>
|
||||
{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>
|
||||
|
|
|
@ -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});
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue