Skip to content

Commit 26f6fb4

Browse files
committed
Dev: remove unnecessary fatalErrors
1 parent 1e30faa commit 26f6fb4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Foundation/URLSession/URLSessionTask.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,10 @@ open class URLSessionTask : NSObject, NSCopying {
256256
open func resume() {
257257
workQueue.sync {
258258
self.suspendCount -= 1
259-
guard 0 <= self.suspendCount else { fatalError("Resuming a task that's not suspended. Calls to resume() / suspend() need to be matched.") }
259+
guard 0 <= self.suspendCount else {
260+
assert(false, "Resuming a task that's not suspended. Calls to resume() / suspend() need to be matched.")
261+
return
262+
}
260263
self.updateTaskState()
261264
if self.suspendCount == 0 {
262265
self.workQueue.async {
@@ -657,7 +660,10 @@ extension _ProtocolClient: URLProtocolClient {
657660
func urlProtocolDidFinishLoading(_ protocol: URLProtocol) {
658661
guard let task = `protocol`.task else { fatalError("task cannot be nil") }
659662
guard let session = task.session as? URLSession else { fatalError("session cannot be nil") }
660-
guard let response = task.response as? HTTPURLResponse else { fatalError("No response") }
663+
guard let response = task.response as? HTTPURLResponse else {
664+
assert(false, "No response")
665+
return
666+
}
661667

662668

663669
if response.statusCode == 401, `protocol`.containsTaskDelegate() {

0 commit comments

Comments
 (0)