aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-25 00:49:28 +0800
committerobscuren <geffobscura@gmail.com>2015-03-25 00:49:28 +0800
commitc38a3b4cc7b7dc62c7fca9cd46a880b036462a27 (patch)
treeb82bb1eb9e7bb7a9eeefe152979ea67ef62b2394 /cmd
parent9de1ad65460898ab79c02ce076f1a2b0a7144656 (diff)
downloaddexon-c38a3b4cc7b7dc62c7fca9cd46a880b036462a27.tar
dexon-c38a3b4cc7b7dc62c7fca9cd46a880b036462a27.tar.gz
dexon-c38a3b4cc7b7dc62c7fca9cd46a880b036462a27.tar.bz2
dexon-c38a3b4cc7b7dc62c7fca9cd46a880b036462a27.tar.lz
dexon-c38a3b4cc7b7dc62c7fca9cd46a880b036462a27.tar.xz
dexon-c38a3b4cc7b7dc62c7fca9cd46a880b036462a27.tar.zst
dexon-c38a3b4cc7b7dc62c7fca9cd46a880b036462a27.zip
Better error reporting in the console. Updated ethereum.js
Diffstat (limited to 'cmd')
-rw-r--r--cmd/ethereum/js.go22
-rw-r--r--cmd/mist/assets/examples/coin.html4
2 files changed, 15 insertions, 11 deletions
diff --git a/cmd/ethereum/js.go b/cmd/ethereum/js.go
index 6f0ac526f..1f0033daa 100644
--- a/cmd/ethereum/js.go
+++ b/cmd/ethereum/js.go
@@ -31,6 +31,7 @@ import (
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/xeth"
"github.com/peterh/liner"
+ "github.com/robertkrimen/otto"
)
type prompter interface {
@@ -101,8 +102,7 @@ func (js *jsre) apiBindings() {
jethObj := t.Object()
jethObj.Set("send", jeth.Send)
- _, err := js.re.Eval(re.BigNumber_JS)
-
+ err := js.re.Compile("bignum.js", re.BigNumber_JS)
if err != nil {
utils.Fatalf("Error loading bignumber.js: %v", err)
}
@@ -113,12 +113,12 @@ func (js *jsre) apiBindings() {
utils.Fatalf("Error defining setTimeout: %v", err)
}
- _, err = js.re.Eval(re.Ethereum_JS)
+ err = js.re.Compile("ethereum.js", re.Ethereum_JS)
if err != nil {
utils.Fatalf("Error loading ethereum.js: %v", err)
}
- _, err = js.re.Eval("var web3 = require('web3');")
+ _, err = js.re.Eval("var web3 = require('ethereum.js');")
if err != nil {
utils.Fatalf("Error requiring web3: %v", err)
}
@@ -128,10 +128,10 @@ func (js *jsre) apiBindings() {
utils.Fatalf("Error setting web3 provider: %v", err)
}
_, err = js.re.Eval(`
- var eth = web3.eth;
- var shh = web3.shh;
- var db = web3.db;
- var net = web3.net;
+var eth = web3.eth;
+var shh = web3.shh;
+var db = web3.db;
+var net = web3.net;
`)
if err != nil {
utils.Fatalf("Error setting namespaces: %v", err)
@@ -211,7 +211,11 @@ func (self *jsre) parseInput(code string) {
}()
value, err := self.re.Run(code)
if err != nil {
- fmt.Println(err)
+ if ottoErr, ok := err.(*otto.Error); ok {
+ fmt.Println(ottoErr.String())
+ } else {
+ fmt.Println(err)
+ }
return
}
self.printValue(value)
diff --git a/cmd/mist/assets/examples/coin.html b/cmd/mist/assets/examples/coin.html
index 96f2299a5..bcd4ad990 100644
--- a/cmd/mist/assets/examples/coin.html
+++ b/cmd/mist/assets/examples/coin.html
@@ -3,7 +3,7 @@
<title>JevCoin</title>
<head>
<script type="text/javascript" src="../ext/bignumber.min.js"></script>
-<script type="text/javascript" src="../ext/ethereum.js/dist/ethereum.js"></script>
+<script type="text/javascript" src="/Users/jeffrey/ethereum.js"></script>
</head>
<body>
@@ -32,7 +32,7 @@
</body>
<script type="text/javascript">
- var web3 = require('web3');
+ var web3 = require('ethereum.js');
var eth = web3.eth;
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));