swifter
swifter copied to clipboard
How to fail with an NSError?
An URLSession data task can fail with an error according to:
open func dataTask(with request: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Swift.Void) -> URLSessionDataTask
Is there any way to fail with an NSError at the moment? I know that Nocilla for example is capable of failing like this.
If not i'd like to rise the proposal:
server["some/path"] = { _ in
return HttpResponse.fail(NSError.notConnected)
}
This is an example where the OS is throwing a notConnected in case the customer does not have an internet connection. (Used in testing)
I'd like to see this in Swifter too.
My fault got that Nocilla is doing something completely different.