Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Sources/FoundationNetworking/URLSession/NativeProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,11 @@ internal class _NativeProtocol: URLProtocol, _EasyHandleDelegate {
}

guard let response = ts.response else {
fatalError("Transfer completed, but there's no response.")
internalState = .transferFailed
let error = NSError(domain: NSURLErrorDomain, code: NSURLErrorNetworkConnectionLost,
userInfo: [NSLocalizedDescriptionKey: "The network connection was lost."])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep the message in the error description?

Suggested change
userInfo: [NSLocalizedDescriptionKey: "The network connection was lost."])
userInfo: [NSLocalizedDescriptionKey: "Transfer completed, but there's no response."])

failWith(error: error, request: request)
return
}
internalState = .transferCompleted(response: response, bodyDataDrain: ts.bodyDataDrain)
let action = completionAction(forCompletedRequest: request, response: response)
Expand Down