diff options
Diffstat (limited to 'cmd/geth/js.go')
-rw-r--r-- | cmd/geth/js.go | 16 |
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() { |