Update: Matching NSErrors

While my original post on this topic might be of some small interest in a general "strategies for using expression patterns" kind of way, Swift provides a much better solution for the specific problem of matching NSErrors.

What does that mean in practice? You can find all the gory details in SE-0112, but the long and the short of it is, depending on the domain of a given NSError, Swift automatically bridges it to a struct describing that domain. In the case of NSURLErrorDomain, for example, Swift will bridge to a URLError:

This alone lets us deal with NSErrors in a much more declarative way without thinking about domains (and that's not to mention all the goodies it gives us that we used to have to dig through userInfo for — like failingURL!)