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

Function Code

status/status.go:139–146  ·  status/status.go::Code

Code returns the Code of the error if it is a Status error or if it wraps a Status error. If that is not the case, it returns codes.OK if err is nil, or codes.Unknown otherwise.

(err error)

Source from the content-addressed store, hash-verified

137// Status error. If that is not the case, it returns codes.OK if err is nil, or
138// codes.Unknown otherwise.
139func Code(err error) codes.Code {
140 // Don't use FromError to avoid allocation of OK status.
141 if err == nil {
142 return codes.OK
143 }
144
145 return Convert(err).Code()
146}
147
148// FromContextError converts a context error or wrapped context error into a
149// Status. It returns a Status with codes.OK if err is nil, or a Status with

Calls 2

ConvertFunction · 0.85
CodeMethod · 0.80