MCPcopy
hub / github.com/grpc/grpc-go / toRPCErr

Function toRPCErr

rpc_util.go:1133–1157  ·  view source on GitHub ↗

toRPCErr converts an error into an error from the status package.

(err error)

Source from the content-addressed store, hash-verified

1131
1132// toRPCErr converts an error into an error from the status package.
1133func toRPCErr(err error) error {
1134 switch err {
1135 case nil, io.EOF:
1136 return err
1137 case context.DeadlineExceeded:
1138 return errContextDeadline
1139 case context.Canceled:
1140 return errContextCanceled
1141 case io.ErrUnexpectedEOF:
1142 return status.Error(codes.Internal, err.Error())
1143 }
1144
1145 switch e := err.(type) {
1146 case transport.ConnectionError:
1147 return status.Error(codes.Unavailable, e.Desc)
1148 case *transport.NewStreamError:
1149 return toRPCErr(e.Err)
1150 }
1151
1152 if _, ok := status.FromError(err); ok {
1153 return err
1154 }
1155
1156 return status.Error(codes.Unknown, err.Error())
1157}
1158
1159// setCallInfoCodec should only be called after CallOptions have been applied.
1160func setCallInfoCodec(c *callInfo) error {

Callers 15

processUnaryRPCMethod · 0.85
processStreamingRPCMethod · 0.85
SendHeaderFunction · 0.85
newClientStreamFunction · 0.85
newAttemptLockedMethod · 0.85
newStreamMethod · 0.85
retryLockedMethod · 0.85
withRetryMethod · 0.85
HeaderMethod · 0.85
recvMsgMethod · 0.85
newNonRetryClientStreamFunction · 0.85

Calls 3

ErrorFunction · 0.92
FromErrorFunction · 0.92
ErrorMethod · 0.65

Tested by 1

TestToRPCErrMethod · 0.68