EqualTypeMark checks whether `GetTypeMark(e1).Equals(GetTypeMark(e2))`. It is written to be be optimized for the case where neither error has serialized type information.
(e1, e2 error)
| 309 | // is written to be be optimized for the case where neither error has |
| 310 | // serialized type information. |
| 311 | func EqualTypeMark(e1, e2 error) bool { |
| 312 | slowPath := func(err error) bool { |
| 313 | switch err.(type) { |
| 314 | case *opaqueLeaf: |
| 315 | return true |
| 316 | case *opaqueLeafCauses: |
| 317 | return true |
| 318 | case *opaqueWrapper: |
| 319 | return true |
| 320 | case TypeKeyMarker: |
| 321 | return true |
| 322 | } |
| 323 | return false |
| 324 | } |
| 325 | if slowPath(e1) || slowPath(e2) { |
| 326 | return GetTypeMark(e1).Equals(GetTypeMark(e2)) |
| 327 | } |
| 328 | |
| 329 | return reflect.TypeOf(e1) == reflect.TypeOf(e2) |
| 330 | } |
| 331 | |
| 332 | // RegisterLeafEncoder can be used to register new leaf error types to |
| 333 | // the library. Registered types will be encoded using their own |
no test coverage detected
searching dependent graphs…