diff options
author | Péter Szilágyi <peterke@gmail.com> | 2019-04-02 18:59:39 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2019-04-02 20:18:05 +0800 |
commit | 3baed8dd9a173eaba704a6fb0b42efe01471b968 (patch) | |
tree | c24235a83142ea5ffda582d212da2b3060ac6393 | |
parent | c4109d790ffd26d67feb7745d4af8a8bc5090bd9 (diff) | |
download | go-tangerine-3baed8dd9a173eaba704a6fb0b42efe01471b968.tar go-tangerine-3baed8dd9a173eaba704a6fb0b42efe01471b968.tar.gz go-tangerine-3baed8dd9a173eaba704a6fb0b42efe01471b968.tar.bz2 go-tangerine-3baed8dd9a173eaba704a6fb0b42efe01471b968.tar.lz go-tangerine-3baed8dd9a173eaba704a6fb0b42efe01471b968.tar.xz go-tangerine-3baed8dd9a173eaba704a6fb0b42efe01471b968.tar.zst go-tangerine-3baed8dd9a173eaba704a6fb0b42efe01471b968.zip |
console: handle eth.coinbase throws
-rw-r--r-- | console/console.go | 26 | ||||
-rw-r--r-- | rpc/handler.go | 2 |
2 files changed, 18 insertions, 10 deletions
diff --git a/console/console.go b/console/console.go index 50196d7f4..5326ed2c8 100644 --- a/console/console.go +++ b/console/console.go @@ -274,14 +274,22 @@ func (c *Console) AutoCompleteInput(line string, pos int) (string, []string, str // Welcome show summary of current Geth instance and some metadata about the // console's available modules. func (c *Console) Welcome() { + message := "Welcome to the Geth JavaScript console!\n\n" + // Print some generic Geth metadata - fmt.Fprintf(c.printer, "Welcome to the Geth JavaScript console!\n\n") - c.jsre.Run(` - console.log("instance: " + web3.version.node); - console.log("coinbase: " + eth.coinbase); - console.log("at block: " + eth.blockNumber + " (" + new Date(1000 * eth.getBlock(eth.blockNumber).timestamp) + ")"); - console.log(" datadir: " + admin.datadir); - `) + if res, err := c.jsre.Run(` + var message = "instance: " + web3.version.node + "\n"; + try { + message += "coinbase: " + eth.coinbase + "\n"; + } catch (err) {} + message += "at block: " + eth.blockNumber + " (" + new Date(1000 * eth.getBlock(eth.blockNumber).timestamp) + ")\n"; + try { + message += " datadir: " + admin.datadir + "\n"; + } catch (err) {} + message + `); err == nil { + message += res.String() + } // List all the supported modules for the user to call if apis, err := c.client.SupportedModules(); err == nil { modules := make([]string, 0, len(apis)) @@ -289,9 +297,9 @@ func (c *Console) Welcome() { modules = append(modules, fmt.Sprintf("%s:%s", api, version)) } sort.Strings(modules) - fmt.Fprintln(c.printer, " modules:", strings.Join(modules, " ")) + message += " modules: " + strings.Join(modules, " ") + "\n" } - fmt.Fprintln(c.printer) + fmt.Fprintln(c.printer, message) } // Evaluate executes code and pretty prints the result to the specified output diff --git a/rpc/handler.go b/rpc/handler.go index bc03ef25f..92db89e2f 100644 --- a/rpc/handler.go +++ b/rpc/handler.go @@ -297,7 +297,7 @@ func (h *handler) handleCallMsg(ctx *callProc, msg *jsonrpcMessage) *jsonrpcMess case msg.isCall(): resp := h.handleCall(ctx, msg) if resp.Error != nil { - h.log.Info("Served "+msg.Method, "reqid", idForLog{msg.ID}, "t", time.Since(start), "err", resp.Error.Message) + h.log.Warn("Served "+msg.Method, "reqid", idForLog{msg.ID}, "t", time.Since(start), "err", resp.Error.Message) } else { h.log.Debug("Served "+msg.Method, "reqid", idForLog{msg.ID}, "t", time.Since(start)) } |