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)
| 137 | // Status error. If that is not the case, it returns codes.OK if err is nil, or |
| 138 | // codes.Unknown otherwise. |
| 139 | func 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 |