From 311d18ae92eedb3afd2aa552c3dfffbf378e656d Mon Sep 17 00:00:00 2001 From: Giulio rebuffo Date: Wed, 3 Aug 2022 02:49:06 +0200 Subject: [PATCH] better error (#4907) Co-authored-by: giuliorebuffo --- core/genesis.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/genesis.go b/core/genesis.go index eb424e16e..c737308de 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -156,7 +156,11 @@ type GenesisMismatchError struct { } func (e *GenesisMismatchError) Error() string { - return fmt.Sprintf("database contains incompatible genesis (have %x, new %x)", e.Stored, e.New) + config := params.ChainConfigByGenesisHash(e.Stored) + if config == nil { + return fmt.Sprintf("database contains incompatible genesis (have %x, new %x)", e.Stored, e.New) + } + return fmt.Sprintf("database contains incompatible genesis (try with --chain=%s)", config.ChainName) } // CommitGenesisBlock writes or updates the genesis block in db.