Skip to content

Matching errors without checking NSError's userInfo dictionary #615

@csiszarattila

Description

@csiszarattila

Hi,

I try to write a simple match for an UrlError:

  expect(error).to(
     matchError(NSError(domain: NSURLErrorDomain, code: URLError.timedOut.rawValue, userInfo: nil)
  )

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions