aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/geth/js.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-04-26 16:39:19 +0800
committerFelix Lange <fjl@twurst.com>2016-04-26 16:39:19 +0800
commit3d6d828caf2dbf2e7ceeeb6f0d38c3b654aefcd2 (patch)
treee2f449e08d17977cc47331f02c43a28a11e78f10 /cmd/geth/js.go
parent70b8b54cd2413fb01e279890b2ddb5eb9bc227c2 (diff)
parent87ae0df476cf6b413795ee54207e8ec86e178dbc (diff)
downloadgo-tangerine-3d6d828caf2dbf2e7ceeeb6f0d38c3b654aefcd2.tar
go-tangerine-3d6d828caf2dbf2e7ceeeb6f0d38c3b654aefcd2.tar.gz
go-tangerine-3d6d828caf2dbf2e7ceeeb6f0d38c3b654aefcd2.tar.bz2
go-tangerine-3d6d828caf2dbf2e7ceeeb6f0d38c3b654aefcd2.tar.lz
go-tangerine-3d6d828caf2dbf2e7ceeeb6f0d38c3b654aefcd2.tar.xz
go-tangerine-3d6d828caf2dbf2e7ceeeb6f0d38c3b654aefcd2.tar.zst
go-tangerine-3d6d828caf2dbf2e7ceeeb6f0d38c3b654aefcd2.zip
Merge pull request #2478 from fjl/geth-js-tweak
cmd/geth, jsre: improve the js command
Diffstat (limited to 'cmd/geth/js.go')
-rw-r--r--cmd/geth/js.go16
1 files changed, 7 insertions, 9 deletions
diff --git a/cmd/geth/js.go b/cmd/geth/js.go
index 767b513c1..2b64303b2 100644
--- a/cmd/geth/js.go
+++ b/cmd/geth/js.go
@@ -123,7 +123,7 @@ func (self *jsre) batch(statement string) {
err := self.re.EvalAndPrettyPrint(statement)
if err != nil {
- fmt.Printf("error: %v", err)
+ fmt.Printf("%v", jsErrorString(err))
}
if self.atexit != nil {
@@ -301,21 +301,19 @@ func (self *jsre) preloadJSFiles(ctx *cli.Context) error {
for _, file := range jsFiles {
filename := common.AbsolutePath(assetPath, strings.TrimSpace(file))
if err := self.re.Exec(filename); err != nil {
- return fmt.Errorf("%s: %v", file, err)
+ return fmt.Errorf("%s: %v", file, jsErrorString(err))
}
}
}
return nil
}
-// exec executes the JS file with the given filename and stops the JSRE
-func (self *jsre) exec(filename string) error {
- if err := self.re.Exec(filename); err != nil {
- self.re.Stop(false)
- return fmt.Errorf("Javascript Error: %v", err)
+// jsErrorString adds a backtrace to errors generated by otto.
+func jsErrorString(err error) string {
+ if ottoErr, ok := err.(*otto.Error); ok {
+ return ottoErr.String()
}
- self.re.Stop(true)
- return nil
+ return err.Error()
}
func (self *jsre) interactive() {