Code of the error. If the code is invalid or unknown, this tries to get the code from the cause of this error. This code is consistent with google.golang.org/genproto/googleapis/rpc/code and google.golang.org/grpc/codes.
()
| 29 | // If the code is invalid or unknown, this tries to get the code from the cause of this error. |
| 30 | // This code is consistent with google.golang.org/genproto/googleapis/rpc/code and google.golang.org/grpc/codes. |
| 31 | func (e *Error) Code() uint32 { |
| 32 | if e == nil { |
| 33 | return 0 |
| 34 | } |
| 35 | if e.code != 0 && e.code != uint32(codes.Unknown) { |
| 36 | return e.code |
| 37 | } |
| 38 | if e.cause != nil { |
| 39 | return Code(e.cause) |
| 40 | } |
| 41 | return uint32(codes.Unknown) |
| 42 | } |
| 43 | |
| 44 | func code(err error) uint32 { |
| 45 | switch { |