summaryrefslogtreecommitdiff
path: root/platform/macos/src
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2017-03-15 16:08:12 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2017-03-17 11:25:48 +0200
commitdf0dfa162b4196f22af1742e1f898ec1fd63a88e (patch)
tree0de4c99bc4aade48efc82b74b4a6dd73fa886541 /platform/macos/src
parente7c1ba2edf8bdb8fbe8ffe0c15908b6beac517ce (diff)
downloadqtlocation-mapboxgl-df0dfa162b4196f22af1742e1f898ec1fd63a88e.tar.gz
[macos] Update changes in MapObserver::onDidFailLoadingMap
Diffstat (limited to 'platform/macos/src')
-rw-r--r--platform/macos/src/MGLMapView.mm32
1 files changed, 26 insertions, 6 deletions
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm
index 127fe79325..5a5073e22d 100644
--- a/platform/macos/src/MGLMapView.mm
+++ b/platform/macos/src/MGLMapView.mm
@@ -35,8 +35,10 @@
#import <mbgl/math/wrap.hpp>
#import <mbgl/util/constants.hpp>
#import <mbgl/util/chrono.hpp>
+#import <mbgl/util/exception.hpp>
#import <mbgl/util/run_loop.hpp>
#import <mbgl/util/shared_thread_pool.hpp>
+#import <mbgl/util/string.hpp>
#import <map>
#import <unordered_map>
@@ -889,18 +891,17 @@ public:
}
}
-- (void)mapViewDidFailLoadingMap {
+- (void)mapViewDidFailLoadingMapWithError:(NSError *)error {
if (!_mbglMap) {
return;
}
if ([self.delegate respondsToSelector:@selector(mapViewDidFailLoadingMap:withError:)]) {
- NSError *error = [NSError errorWithDomain:MGLErrorDomain code:0 userInfo:nil];
[self.delegate mapViewDidFailLoadingMap:self withError:error];
}
}
-- (void)MapViewWillStartRenderingFrame {
+- (void)mapViewWillStartRenderingFrame {
if (!_mbglMap) {
return;
}
@@ -2794,12 +2795,31 @@ public:
[nativeView mapViewDidFinishLoadingMap];
}
- void onDidFailLoadingMap() override {
- [nativeView mapViewDidFailLoadingMap];
+ void onDidFailLoadingMap(std::exception_ptr exception) override {
+ NSString *description;
+ MGLErrorCode code;
+ try {
+ std::rethrow_exception(exception);
+ } catch (const mbgl::util::StyleParseException&) {
+ code = MGLErrorCodeParseStyleFailed;
+ description = NSLocalizedStringWithDefaultValue(@"PARSE_STYLE_FAILED_DESC", nil, nil, @"The map failed to load because the style is corrupted.", @"");
+ } catch (const mbgl::util::StyleLoadException&) {
+ code = MGLErrorCodeLoadStyleFailed;
+ description = NSLocalizedStringWithDefaultValue(@"PARSE_STYLE_FAILED_DESC", nil, nil, @"The map failed to load because the style can't be loaded.", @"");
+ } catch (const mbgl::util::NotFoundException&) {
+ code = MGLErrorCodeNotFound;
+ description = NSLocalizedStringWithDefaultValue(@"LOAD_STYLE_FAILED_DESC", nil, nil, @"The map failed to load because the style can’t be found or is incompatible.", @"");
+ } catch (...) {
+ code = MGLErrorCodeUnknown;
+ description = NSLocalizedStringWithDefaultValue(@"LOAD_STYLE_FAILED_DESC", nil, nil, @"The map failed to load because an unknown error occurred.", @"");
+ }
+ NSDictionary *userInfo = @{NSLocalizedDescriptionKey:description, NSLocalizedFailureReasonErrorKey:@(mbgl::util::toString(exception).c_str())};
+ NSError *error = [NSError errorWithDomain:MGLErrorDomain code:code userInfo:userInfo];
+ [nativeView mapViewDidFailLoadingMapWithError:error];
}
void onWillStartRenderingFrame() override {
- [nativeView MapViewWillStartRenderingFrame];
+ [nativeView mapViewWillStartRenderingFrame];
}
void onDidFinishRenderingFrame(mbgl::MapObserver::RenderMode mode) override {