Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

MGLGeoJSONSource does not handle exceptions from GeoJSON parsing #6987

Closed
jfirebaugh opened this issue Nov 9, 2016 · 3 comments
Closed

MGLGeoJSONSource does not handle exceptions from GeoJSON parsing #6987

jfirebaugh opened this issue Nov 9, 2016 · 3 comments
Assignees
Labels
good first issue Good for newcomers iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS runtime styling
Milestone

Comments

@jfirebaugh
Copy link
Contributor

The following code crashes the application with

libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: Feature must have a geometry property

It should instead raise the error using appropriate cocoa error reporting mechanism.

    MGLGeoJSONSource *geojsonSource = [[MGLGeoJSONSource alloc]
        initWithIdentifier:@"geojson"
               geoJSONData:[@"{\"type\": \"Feature\", \"feature\": {\"type\": \"Point\", \"coordinates\": [0, 0]}}" dataUsingEncoding:NSUTF8StringEncoding]
                   options:nil];
@jfirebaugh jfirebaugh added iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS labels Nov 9, 2016
@nitrag
Copy link
Contributor

nitrag commented Nov 10, 2016

In the event that I query several hundred features, I wouldn't want it to fail just because one feature was corrupted and didn't have a geometry. Rather, it should throw a warning and ignore/skip that particular feature.

@1ec5 1ec5 self-assigned this Dec 11, 2016
@1ec5 1ec5 added this to the ios-v3.4.0 milestone Dec 11, 2016
@1ec5
Copy link
Contributor

1ec5 commented Dec 12, 2016

#7334 renamed MGLGeoJSONSource to MGLShapeSource. #7377 removes the crashing initializer in favor of a general-purpose deserialization method (for #3630). This method handles errors gracefully via an NSError out parameter, which is represented as the throws keyword in Swift.

@1ec5
Copy link
Contributor

1ec5 commented Dec 14, 2016

Fixed in #7377 on the iOS SDK v3.4.0 release branch.

@1ec5 1ec5 closed this as completed Dec 14, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS runtime styling
Projects
None yet
Development

No branches or pull requests

4 participants