Code gets the code of an error. If the error doesn't implement codes, Unknown is returned.
(err error)
| 60 | // Code gets the code of an error. |
| 61 | // If the error doesn't implement codes, Unknown is returned. |
| 62 | func Code(err error) uint32 { |
| 63 | if err == nil { |
| 64 | return uint32(codes.OK) |
| 65 | } |
| 66 | if code := code(err); code != 0 { |
| 67 | return code |
| 68 | } |
| 69 | return uint32(codes.Unknown) |
| 70 | } |
| 71 | |
| 72 | // HasCode returns whether the given error has the given error code. |
| 73 | // If the error doesn't implement codes, it doesn't have any code. |
no test coverage detected