Skip to content

Commit bb81334

Browse files
committed
[FAB-11468] Print error upon peer cmd failure
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>
1 parent 668456b commit bb81334

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

peer/channel/getinfo.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (cc *endorserClient) getBlockChainInfo() (*cb.BlockchainInfo, error) {
6969
}
7070

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

7575
blockChainInfo := &cb.BlockchainInfo{}

peer/channel/join.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func executeJoin(cf *ChannelCmdFactory) (err error) {
122122
}
123123

124124
if proposalResp.Response.Status != 0 && proposalResp.Response.Status != 200 {
125-
return ProposalFailedErr(fmt.Sprintf("bad proposal response %d", proposalResp.Response.Status))
125+
return ProposalFailedErr(fmt.Sprintf("bad proposal response %d: %s", proposalResp.Response.Status, proposalResp.Response.Message))
126126
}
127127
logger.Info("Successfully submitted proposal to join channel")
128128
return nil

peer/channel/list.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func (cc *endorserClient) getChannels() ([]*pb.ChannelInfo, error) {
8080
}
8181

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

8686
var channelQueryResponse pb.ChannelQueryResponse

peer/common/common.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func GetOrdererEndpointOfChain(chainID string, signer msp.SigningIdentity, endor
187187
}
188188

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

193193
// parse config block

0 commit comments

Comments
 (0)