mpclarkson / StravaSwift

A Swift wrapper for the Strava API v3
MIT License
102 stars 45 forks source link

No error response from request if network unavailable #20

Open FleetPhil opened 4 years ago

FleetPhil commented 4 years ago

I ran a data request with airplane mode set on the target iPhone expecting an error response from the Strava Client, however I don't seem to get any response from the Alamofire request - the debug output shows the expected error but as far as I can see this message is coming from the Foundation library, not StravaSwift or Alamofire:

2019-10-23 18:31:24.637011+0100 RideViewer2[6907:2217779] Task <31B1E946-16F8-4DB1-8B7E-773E6D2DD9A4>.<1> finished with error [-1009] Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={_kCFStreamErrorCodeKey=50, NSUnderlyingError=0x28093a7f0 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <31B1E946-16F8-4DB1-8B7E-773E6D2DD9A4>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=( "LocalDataTask <31B1E946-16F8-4DB1-8B7E-773E6D2DD9A4>.<1>" ), NSLocalizedDescription=The Internet connection appears to be offline., NSErrorFailingURLStringKey=https://www.strava.com/api/v3/athlete/activities?after=1571147109&page=1&per_page=100, NSErrorFailingURLKey=https://www.strava.com/api/v3/athlete/activities?after=1571147109&page=1&per_page=100, _kCFStreamErrorDomainKey=1}

I suspect that this issue is related to the one in this thread - https://github.com/Alamofire/Alamofire/issues/2311 - but my expertise is not good enough to confirm this or work out a fix...

Any thoughts?