diff options
Diffstat (limited to 'platform/darwin/src/MGLStyle.mm')
-rw-r--r-- | platform/darwin/src/MGLStyle.mm | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm index 5768a7aaa7..cab0eaae28 100644 --- a/platform/darwin/src/MGLStyle.mm +++ b/platform/darwin/src/MGLStyle.mm @@ -226,12 +226,23 @@ static_assert(6 == mbgl::util::default_styles::numOrderedStyles, MGLLogDebug(@"Removing source: %@", source); if (!source.rawSource) { - [NSException raise:NSInvalidArgumentException format: - @"The source %@ cannot be removed from the style. " - @"Make sure the source was created as a member of a concrete subclass of MGLSource.", - source]; + NSString *errorMessage = [NSString stringWithFormat: + @"The source %@ cannot be removed from the style. " + @"Make sure the source was created as a member of a concrete subclass of MGLSource." + @"Automatic re-addition of sources after style changes is not currently supported.", + source]; + + if (outError) { + *outError = [NSError errorWithDomain:MGLErrorDomain + code:MGLErrorCodeSourceCannotBeRemovedFromStyle + userInfo:@{ NSLocalizedDescriptionKey : errorMessage }]; + return NO; + } + else { + [NSException raise:NSInvalidArgumentException format:@"%@", errorMessage]; + } } - + return [source removeFromMapView:self.mapView error:outError]; } |