Skip to content

Commit 8896069

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 f10cd75 commit 8896069

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

peer/channel/getinfo.go

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func GetOrdererEndpointOfChain(chainID string, signer msp.SigningIdentity, endor
205205
}
206206

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

211211
// parse config block

0 commit comments

Comments
 (0)