3lvis / Networking

Swift HTTP Networking with stubbing and caching support
MIT License
1.36k stars 112 forks source link

Add error convenience accessor #197

Closed 3lvis closed 7 years ago

3lvis commented 7 years ago

Useful for when you don't care about the result but more if there's an error or not.

Before:

networking.get("/somepath") { result in 
    switch result {
    case .success:
        completion(nil)
    case .failure(let response):
        completion(response.error)
    }
}

Now:

networking.get("/somepath") { result in 
    completion(result.error) // NSError?
}