Skip to content
This repository has been archived by the owner on Oct 17, 2022. It is now read-only.

Commit

Permalink
Add error handling to Greeter tutorial (#774)
Browse files Browse the repository at this point in the history
* Add error handling to Greeter tutorial

While trying to get up and running with contract deployment through geth, I spent multiple hours trying to debug the `greeterFactory.new(...)` command in this tutorial without realizing that I was getting an "Error: exceeds block gas limit" error. This change makes it so that the console will log if contract deployment fails.

* Use early return for error handling.
  • Loading branch information
an1lam authored and alexvansande committed Jan 24, 2018
1 parent 003790e commit 1ec49e0
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions views/content/greeter.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,17 @@ You have now compiled your code and made it available to Geth. Now you need to
var _greeting = "Hello World!"

var greeter = greeterFactory.new(_greeting,{from:eth.accounts[0],data:greeterCompiled,gas:47000000}, function(e, contract){
if(!e) {

if(!contract.address) {
console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined...");
if(e) {
console.error(e); // If something goes wrong, at least we'll know.
return;
}

} else {
console.log("Contract mined! Address: " + contract.address);
console.log(contract);
}
if(!contract.address) {
console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined...");

} else {
console.log("Contract mined! Address: " + contract.address);
console.log(contract);
}
})

Expand Down

0 comments on commit 1ec49e0

Please sign in to comment.