summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLStyle.mm
diff options
context:
space:
mode:
Diffstat (limited to 'platform/darwin/src/MGLStyle.mm')
-rw-r--r--platform/darwin/src/MGLStyle.mm38
1 files changed, 31 insertions, 7 deletions
diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm
index c84782dba9..1e60b956c7 100644
--- a/platform/darwin/src/MGLStyle.mm
+++ b/platform/darwin/src/MGLStyle.mm
@@ -287,10 +287,18 @@ static NSURL *MGLStyleURL_emerald;
[NSException raise:NSRangeException
format:@"Cannot insert style layer at out-of-bounds index %lu.", (unsigned long)index];
} else if (index == 0) {
- [styleLayer addToMapView:self.mapView belowLayer:nil];
+ try {
+ [styleLayer addToMapView:self.mapView belowLayer:nil];
+ } catch (const std::runtime_error & err) {
+ [NSException raise:@"MGLRedundantLayerIdentifierException" format:@"%s", err.what()];
+ }
} else {
- MGLStyleLayer *sibling = [self layerFromMBGLLayer:layers.at(layers.size() - index)];
- [styleLayer addToMapView:self.mapView belowLayer:sibling];
+ try {
+ MGLStyleLayer *sibling = [self layerFromMBGLLayer:layers.at(layers.size() - index)];
+ [styleLayer addToMapView:self.mapView belowLayer:sibling];
+ } catch (std::runtime_error & err) {
+ [NSException raise:@"MGLRedundantLayerIdentifierException" format:@"%s", err.what()];
+ }
}
}
@@ -374,7 +382,11 @@ static NSURL *MGLStyleURL_emerald;
layer];
}
[self willChangeValueForKey:@"layers"];
- [layer addToMapView:self.mapView belowLayer:nil];
+ try {
+ [layer addToMapView:self.mapView belowLayer:nil];
+ } catch (std::runtime_error & err) {
+ [NSException raise:@"MGLRedundantLayerIdentifierException" format:@"%s", err.what()];
+ }
[self didChangeValueForKey:@"layers"];
}
@@ -399,7 +411,11 @@ static NSURL *MGLStyleURL_emerald;
sibling];
}
[self willChangeValueForKey:@"layers"];
- [layer addToMapView:self.mapView belowLayer:sibling];
+ try {
+ [layer addToMapView:self.mapView belowLayer:sibling];
+ } catch (std::runtime_error & err) {
+ [NSException raise:@"MGLRedundantLayerIdentifierException" format:@"%s", err.what()];
+ }
[self didChangeValueForKey:@"layers"];
}
@@ -437,10 +453,18 @@ static NSURL *MGLStyleURL_emerald;
@"Make sure sibling was obtained using -[MGLStyle layerWithIdentifier:].",
sibling];
} else if (index + 1 == layers.size()) {
- [layer addToMapView:self.mapView belowLayer:nil];
+ try {
+ [layer addToMapView:self.mapView belowLayer:nil];
+ } catch (std::runtime_error & err) {
+ [NSException raise:@"MGLRedundantLayerIdentifierException" format:@"%s", err.what()];
+ }
} else {
MGLStyleLayer *sibling = [self layerFromMBGLLayer:layers.at(index + 1)];
- [layer addToMapView:self.mapView belowLayer:sibling];
+ try {
+ [layer addToMapView:self.mapView belowLayer:sibling];
+ } catch (std::runtime_error & err) {
+ [NSException raise:@"MGLRedundantLayerIdentifierException" format:@"%s", err.what()];
+ }
}
[self didChangeValueForKey:@"layers"];
}