From 13304d8a43d2ea83dcb15836e58b3a6b7e5f3205 Mon Sep 17 00:00:00 2001 From: Eneko Alonso Date: Tue, 1 Aug 2017 13:59:34 -0700 Subject: [PATCH] Remove references to NSError (#23) - [x] I've read, understood, and done my best to follow the [*CONTRIBUTING guidelines](../CONTRIBUTING.md). This pull request includes (pick all that apply): - [ ] Bugfixes - [ ] New features - [x] Breaking changes - [ ] Documentation updates - [ ] Unit tests - [ ] Other ### Summary - Remove references to `NSError`, use `Error` instead. ### Implementation - Remove unnecessary casting to `NSError`. ### Test Plan - Run `rake test` --- CHANGELOG.md | 1 + Sources/Conduit/Networking/URLSessionClient.swift | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 816a3e44..7b6f404e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Master #### Breaking +- Remove unnecessary casting to `NSError` on `SessionTaskCompletion`. - `XMLNode.children` is no longer optional, defaults to empty array. #### Enhancements diff --git a/Sources/Conduit/Networking/URLSessionClient.swift b/Sources/Conduit/Networking/URLSessionClient.swift index 8f37695d..dc382413 100644 --- a/Sources/Conduit/Networking/URLSessionClient.swift +++ b/Sources/Conduit/Networking/URLSessionClient.swift @@ -8,7 +8,7 @@ import Foundation -public typealias SessionTaskCompletion = (Data?, URLResponse?, NSError?) -> Void +public typealias SessionTaskCompletion = (Data?, URLResponse?, Error?) -> Void public typealias SessionTaskProgressHandler = (Progress) -> Void fileprivate typealias SessionCompletionHandler = (URLSession.AuthChallengeDisposition, URLCredential?) -> Void @@ -145,7 +145,7 @@ public struct URLSessionClient: URLSessionClientType { taskUploadProgresses[task.taskIdentifier] = nil } - completionHandler?(taskResponse.data, taskResponse.response, taskResponse.error as NSError?) + completionHandler?(taskResponse.data, taskResponse.response, taskResponse.error) } func registerCompletionHandler(taskIdentifier: Int, @@ -284,7 +284,7 @@ public struct URLSessionClient: URLSessionClientType { switch middlewareProcessingResult { case .error(let error): self.urlSession.delegateQueue.addOperation { - completion(nil, nil, error as NSError) + completion(nil, nil, error) } return case .value(let request): @@ -366,7 +366,7 @@ public struct URLSessionClient: URLSessionClientType { // If for some reason the client isn't retained elsewhere, it will at least stay alive // while active tasks are running self.activeTaskQueueDispatchGroup.leave() - completion(data, response, error as NSError?) + completion(data, response, error) } return dataTask