Skip to content

Commit

Permalink
[FAB-8017] Peer CLI fetch cmd error assignment issue
Browse files Browse the repository at this point in the history
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 <wtlahti@us.ibm.com>
  • Loading branch information
wlahti committed Feb 1, 2018
1 parent 0c3673e commit f435c34
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions peer/channel/fetchconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit f435c34

Please sign in to comment.