From f435c342bcdbb79c1286dae3a08f69b48c6a9147 Mon Sep 17 00:00:00 2001 From: Will Lahti Date: Thu, 1 Feb 2018 12:05:00 -0500 Subject: [PATCH] [FAB-8017] Peer CLI fetch cmd error assignment issue This CR fixes the fetch command's error assignment to ensure the correct errors are being assigned and checked before proceeding. With this fix, the end user will receive the correct error message instead of a error message related to marshaling a nil value. Change-Id: I39a32291357ff01f82e1bbd4df2ef6665f77d50b Signed-off-by: Will Lahti --- peer/channel/fetchconfig.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/peer/channel/fetchconfig.go b/peer/channel/fetchconfig.go index f9a24150f35..b276696a440 100644 --- a/peer/channel/fetchconfig.go +++ b/peer/channel/fetchconfig.go @@ -69,18 +69,18 @@ func fetch(cmd *cobra.Command, args []string, cf *ChannelCmdFactory) error { case "newest": block, err = cf.DeliverClient.getNewestBlock() case "config": - iBlock, err := cf.DeliverClient.getNewestBlock() - if err != nil { - return err + iBlock, err2 := cf.DeliverClient.getNewestBlock() + if err2 != nil { + return err2 } - lc, err := utils.GetLastConfigIndexFromBlock(iBlock) - if err != nil { - return err + lc, err2 := utils.GetLastConfigIndexFromBlock(iBlock) + if err2 != nil { + return err2 } block, err = cf.DeliverClient.getSpecifiedBlock(lc) default: - num, err := strconv.Atoi(args[0]) - if err != nil { + num, err2 := strconv.Atoi(args[0]) + if err2 != nil { return fmt.Errorf("fetch target illegal: %s", args[0]) } block, err = cf.DeliverClient.getSpecifiedBlock(uint64(num))