On a network request handled by Alamofire, I often get this error:
The operation could not complete. (Alamofire.AFError error 9.)
Has anyone a clue about what this error 9 is?
I suppose AFError
being an enum and conforming to protocol Error
, this error 9 could be the raw value of the createURLRequestFailed(error:)
case (which is the 10th case in this enum).
AFError enumeration reference
I then implemented some delegate methods in EventMonitor
, like
public func request(_ request: Request, didFailToCreateURLRequestWithError error: AFError)
public func request(_ request: Request, didCompleteTask task: URLSessionTask, with error: AFError?)
public func request(_ request: UploadRequest, didFailToCreateUploadableWithError error: AFError)
public func request(_ request: Request, didFailTask task: URLSessionTask, earlyWithError error: AFError)
but none of these seem to be triggered for this error (especially the first one, which seemed a good fit).
How can I debug this error and find the root cause of the issue?
CodePudding user response:
I found this, where you can debug this by casting the AFError to an NSError or URLError and from there on debug what it is that actually went wrong.