| 1 | package activitypub |
| 2 | |
| 3 | import ( |
| 4 | "github.com/go-ap/errors" |
| 5 | "github.com/google/go-cmp/cmp" |
| 6 | ) |
| 7 | |
| 8 | func areErrors(a, b any) bool { |
| 9 | _, ok1 := a.(error) |
| 10 | _, ok2 := b.(error) |
| 11 | return ok1 && ok2 |
| 12 | } |
| 13 | |
| 14 | func compareErrors(x, y interface{}) bool { |
| 15 | xe := x.(error) |
| 16 | ye := y.(error) |
| 17 | if errors.Is(xe, ye) || errors.Is(ye, xe) { |
| 18 | return true |
| 19 | } |
| 20 | return xe.Error() == ye.Error() |
| 21 | } |
| 22 | |
| 23 | var EquateWeakErrors = cmp.FilterValues(areErrors, cmp.Comparer(compareErrors)) |