Skip to content

Commit 3baed8d

Browse files
committed
console: handle eth.coinbase throws
1 parent c4109d7 commit 3baed8d

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

‎console/console.go‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -274,24 +274,32 @@ func (c *Console) AutoCompleteInput(line string, pos int) (string, []string, str
274274
// Welcome show summary of current Geth instance and some metadata about the
275275
// console's available modules.
276276
func (c *Console) Welcome() {
277+
message := "Welcome to the Geth JavaScript console!\n\n"
278+
277279
// Print some generic Geth metadata
278-
fmt.Fprintf(c.printer, "Welcome to the Geth JavaScript console!\n\n")
279-
c.jsre.Run(`
280-
console.log("instance: " + web3.version.node);
281-
console.log("coinbase: " + eth.coinbase);
282-
console.log("at block: " + eth.blockNumber + " (" + new Date(1000 * eth.getBlock(eth.blockNumber).timestamp) + ")");
283-
console.log(" datadir: " + admin.datadir);
284-
`)
280+
if res, err := c.jsre.Run(`
281+
var message = "instance: " + web3.version.node + "\n";
282+
try {
283+
message += "coinbase: " + eth.coinbase + "\n";
284+
} catch (err) {}
285+
message += "at block: " + eth.blockNumber + " (" + new Date(1000 * eth.getBlock(eth.blockNumber).timestamp) + ")\n";
286+
try {
287+
message += " datadir: " + admin.datadir + "\n";
288+
} catch (err) {}
289+
message
290+
`); err == nil {
291+
message += res.String()
292+
}
285293
// List all the supported modules for the user to call
286294
if apis, err := c.client.SupportedModules(); err == nil {
287295
modules := make([]string, 0, len(apis))
288296
for api, version := range apis {
289297
modules = append(modules, fmt.Sprintf("%s:%s", api, version))
290298
}
291299
sort.Strings(modules)
292-
fmt.Fprintln(c.printer, " modules:", strings.Join(modules, " "))
300+
message += " modules: " + strings.Join(modules, " ") + "\n"
293301
}
294-
fmt.Fprintln(c.printer)
302+
fmt.Fprintln(c.printer, message)
295303
}
296304

297305
// Evaluate executes code and pretty prints the result to the specified output

‎rpc/handler.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ func (h *handler) handleCallMsg(ctx *callProc, msg *jsonrpcMessage) *jsonrpcMess
297297
case msg.isCall():
298298
resp := h.handleCall(ctx, msg)
299299
if resp.Error != nil {
300-
h.log.Info("Served "+msg.Method, "reqid", idForLog{msg.ID}, "t", time.Since(start), "err", resp.Error.Message)
300+
h.log.Warn("Served "+msg.Method, "reqid", idForLog{msg.ID}, "t", time.Since(start), "err", resp.Error.Message)
301301
} else {
302302
h.log.Debug("Served "+msg.Method, "reqid", idForLog{msg.ID}, "t", time.Since(start))
303303
}

0 commit comments

Comments
 (0)