Commit d4adf7ab authored by Gari Singh's avatar Gari Singh
Browse files

[FAB-5141] configtxgen --version should not panic

If configtxgen cannot find a configtx.yaml file,
it panics.  While this in and of itself is ok,
it should not panic when simply trying to get the

Two changes were made:

- move response to --version above all other flags
- added a defer / recover function to better handle
config not found and make things more clear

Change-Id: I512d1fed464c734db7178eb576440c45767f6994
Signed-off-by: default avatarGari Singh <>
parent ace2a64b
......@@ -23,6 +23,7 @@ import (
......@@ -347,17 +348,30 @@ func main() {
// show version
if *version {
logging.SetLevel(logging.INFO, "")
// don't need to panic when running via command line
defer func() {
if err := recover(); err != nil {
if strings.Contains(fmt.Sprint(err), "Error reading configuration: Unsupported Config Type") {
logger.Error("Could not find configtx.yaml. " +
"Please make sure that FABRIC_CFG_PATH is set to a path " +
"which contains configtx.yaml")
logger.Info("Loading configuration")
config := genesisconfig.Load(profile)
if *version {
if outputBlock != "" {
if err := doOutputBlock(config, channelID, outputBlock); err != nil {
logger.Fatalf("Error on outputBlock: %s", err)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment