Skip to content

Commit

Permalink
[FAB-11468] Print error upon peer cmd failure
Browse files Browse the repository at this point in the history
Several peer commands print a 500 error code upon failure,
but do not print the corresponding error message,
making it impossible to troubleshoot.

This CR adds the error message in addition to the error code.

Change-Id: I3c4b9dfee68e0f55723202ac65931d1bc20411ce
Signed-off-by: David Enyeart <enyeart@us.ibm.com>
  • Loading branch information
denyeart committed Aug 3, 2018
1 parent f10cd75 commit 8896069
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion peer/channel/getinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (cc *endorserClient) getBlockChainInfo() (*cb.BlockchainInfo, error) {
}

if proposalResp.Response == nil || proposalResp.Response.Status != 200 {
return nil, errors.Errorf("received bad response, status %d", proposalResp.Response.Status)
return nil, errors.Errorf("received bad response, status %d: %s", proposalResp.Response.Status, proposalResp.Response.Message)
}

blockChainInfo := &cb.BlockchainInfo{}
Expand Down
2 changes: 1 addition & 1 deletion peer/channel/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func executeJoin(cf *ChannelCmdFactory) (err error) {
}

if proposalResp.Response.Status != 0 && proposalResp.Response.Status != 200 {
return ProposalFailedErr(fmt.Sprintf("bad proposal response %d", proposalResp.Response.Status))
return ProposalFailedErr(fmt.Sprintf("bad proposal response %d: %s", proposalResp.Response.Status, proposalResp.Response.Message))
}
logger.Info("Successfully submitted proposal to join channel")
return nil
Expand Down
2 changes: 1 addition & 1 deletion peer/channel/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (cc *endorserClient) getChannels() ([]*pb.ChannelInfo, error) {
}

if proposalResp.Response == nil || proposalResp.Response.Status != 200 {
return nil, errors.New(fmt.Sprint("Received bad response, status", proposalResp.Response.Status))
return nil, errors.New(fmt.Sprintf("Received bad response, status %d: %s", proposalResp.Response.Status, proposalResp.Response.Message))
}

var channelQueryResponse pb.ChannelQueryResponse
Expand Down
2 changes: 1 addition & 1 deletion peer/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func GetOrdererEndpointOfChain(chainID string, signer msp.SigningIdentity, endor
}

if proposalResp.Response.Status != 0 && proposalResp.Response.Status != 200 {
return nil, errors.Errorf("error bad proposal response %d", proposalResp.Response.Status)
return nil, errors.Errorf("error bad proposal response %d: %s", proposalResp.Response.Status, proposalResp.Response.Message)
}

// parse config block
Expand Down

0 comments on commit 8896069

Please sign in to comment.