Matching errors without checking NSError's userInfo dictionary #904
csiszarattila
started this conversation in
Ideas
Replies: 1 comment
-
I'm sorry for the late response. I think that's because Nimble/Sources/Nimble/Matchers/MatchError.swift Lines 34 to 53 in 025d0e2 So I'd say this is an expected behavior. But it may be good to provide another overload which takes an enum NSErrorMatchingStrategy {
case `default` // Rely on `NSError`'s `Equatable` implementation
case ignoringUserInfo // Just compare `domain` and `code` and ignore `userInfo`
}
func matchError(_ error: NSError, strategy: NSErrorMatchingStrategy = .default) -> Predicate<NSError> |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I try to write a simple match for an UrlError:
But it fails, even the error is the same, because matchError seems to also compare the userInfo:
expected to match error <Error Domain=NSURLErrorDomain Code=-1001 "(null)">, got <Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSUnderlyingError=0x600001431260 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, NSErrorFailingURLStringKey=https://example.org/example/end/point, NSErrorFailingURLKey=https://example.org/example/end/point, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2102, NSLocalizedDescription=The request timed out.}>
Is it intentional? Is there a way to overcome this?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions