Resemble returns true iff the given errors resemble, meaning that the Namespace and Name of the errors are equal. A nil error only resembles nil. Invalid errors or definitions (including typed nil) never resemble anything.
(a, b error)
| 18 | // Namespace and Name of the errors are equal. A nil error only resembles nil. |
| 19 | // Invalid errors or definitions (including typed nil) never resemble anything. |
| 20 | func Resemble(a, b error) bool { |
| 21 | if a == nil && b == nil { |
| 22 | return true |
| 23 | } |
| 24 | ttnA, ok := From(a) |
| 25 | if !ok { |
| 26 | return false |
| 27 | } |
| 28 | ttnB, ok := From(b) |
| 29 | if !ok { |
| 30 | return false |
| 31 | } |
| 32 | return ttnA.Namespace() == ttnB.Namespace() && |
| 33 | ttnA.Name() == ttnB.Name() |
| 34 | } |