Code returns the error code of `current error`. It returns `CodeNil` if it has no error code neither it does not implement interface Code.
(err error)
| 115 | // Code returns the error code of `current error`. |
| 116 | // It returns `CodeNil` if it has no error code neither it does not implement interface Code. |
| 117 | func Code(err error) gcode.Code { |
| 118 | if err == nil { |
| 119 | return gcode.CodeNil |
| 120 | } |
| 121 | if e, ok := err.(ICode); ok { |
| 122 | return e.Code() |
| 123 | } |
| 124 | if e, ok := err.(IUnwrap); ok { |
| 125 | return Code(e.Unwrap()) |
| 126 | } |
| 127 | return gcode.CodeNil |
| 128 | } |
| 129 | |
| 130 | // HasCode checks and reports whether `err` has `code` in its chaining errors. |
| 131 | func HasCode(err error, code gcode.Code) bool { |
searching dependent graphs…