From 9c5e1dfe8de91a0f75bba5a7a15b366539fa5558 Mon Sep 17 00:00:00 2001 From: denyeart Date: Sat, 13 Nov 2021 12:36:56 -0500 Subject: [PATCH] Clarify ProcessProposal error handling (#3044) Add comments to clarify ProcessProposal error handling intent. Signed-off-by: David Enyeart --- core/endorser/endorser.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/endorser/endorser.go b/core/endorser/endorser.go index 0f8e2c00fe2..a3d9d6f11cb 100644 --- a/core/endorser/endorser.go +++ b/core/endorser/endorser.go @@ -298,6 +298,9 @@ func (e *Endorser) preProcess(up *UnpackedProposal, channel *Channel) error { } // ProcessProposal process the Proposal +// Errors related to the proposal itself are returned with an error that results in a grpc error. +// Errors related to proposal processing (either infrastructure errors or chaincode errors) are returned with a nil error, +// clients are expected to look at the ProposalResponse response status code (e.g. 500) and message. func (e *Endorser) ProcessProposal(ctx context.Context, signedProp *pb.SignedProposal) (*pb.ProposalResponse, error) { // start time for computing elapsed time metric for successfully endorsed proposals startTime := time.Now() @@ -345,6 +348,7 @@ func (e *Endorser) ProcessProposal(ctx context.Context, signedProp *pb.SignedPro pResp, err := e.ProcessProposalSuccessfullyOrError(up) if err != nil { endorserLogger.Warnw("Failed to invoke chaincode", "channel", up.ChannelHeader.ChannelId, "chaincode", up.ChaincodeName, "error", err.Error()) + // Return a nil error since clients are expected to look at the ProposalResponse response status code (500) and message. return &pb.ProposalResponse{Response: &pb.Response{Status: 500, Message: err.Error()}}, nil }