diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-04-14 11:17:22 -0400 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-04-14 11:17:22 -0400 |
commit | b4ad5157924bb7af289ce68e4e9f008fd6baa90e (patch) | |
tree | e541322cfd9304815c2abdbdee01ec94f40083f6 /macosx/main.mm | |
parent | e34fc8a303e2bb66c0b76d3d2ebe407c4a92d528 (diff) | |
download | qtlocation-mapboxgl-b4ad5157924bb7af289ce68e4e9f008fd6baa90e.tar.gz |
don't report intentionally cancelled HTTP requests as error on os x + ios
Diffstat (limited to 'macosx/main.mm')
-rw-r--r-- | macosx/main.mm | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/macosx/main.mm b/macosx/main.mm index 705bff8ff5..269d2bc6ed 100644 --- a/macosx/main.mm +++ b/macosx/main.mm @@ -48,12 +48,19 @@ Request *request_http(std::string url, std::function<void(Response&)> background { NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:[NSURL URLWithString:@(url.c_str())] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + if ([error code] == NSURLErrorCancelled) { + // We intentionally cancelled this request. Do nothing. + return; + } + Response res; if ( ! error && [response isKindOfClass:[NSHTTPURLResponse class]]) { res.code = [(NSHTTPURLResponse *)response statusCode]; res.body = { (const char *)[data bytes], [data length] }; + } else { + NSLog(@"http error (%s): %@", url.c_str(), [error localizedDescription]); } background_function(res); |