diff options
Diffstat (limited to 'platform/macos/src/MGLMapView.mm')
-rw-r--r-- | platform/macos/src/MGLMapView.mm | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index fa207ec187..7edf34574d 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -3062,27 +3062,29 @@ public: [nativeView mapViewDidFinishLoadingMap]; } - void onDidFailLoadingMap(std::exception_ptr exception) override { + void onDidFailLoadingMap(mbgl::MapLoadError mapError, const std::string& what) 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.", @"User-friendly error description"); - } catch (const mbgl::util::StyleLoadException&) { - code = MGLErrorCodeLoadStyleFailed; - description = NSLocalizedStringWithDefaultValue(@"LOAD_STYLE_FAILED_DESC", nil, nil, @"The map failed to load because the style can't be loaded.", @"User-friendly error description"); - } catch (const mbgl::util::NotFoundException&) { - code = MGLErrorCodeNotFound; - description = NSLocalizedStringWithDefaultValue(@"STYLE_NOT_FOUND_DESC", nil, nil, @"The map failed to load because the style can’t be found or is incompatible.", @"User-friendly error description"); - } catch (...) { - code = MGLErrorCodeUnknown; - description = NSLocalizedStringWithDefaultValue(@"LOAD_MAP_FAILED_DESC", nil, nil, @"The map failed to load because an unknown error occurred.", @"User-friendly error description"); + switch (mapError) { + case mbgl::MapLoadError::StyleParseError: + code = MGLErrorCodeParseStyleFailed; + description = NSLocalizedStringWithDefaultValue(@"PARSE_STYLE_FAILED_DESC", nil, nil, @"The map failed to load because the style is corrupted.", @"User-friendly error description"); + break; + case mbgl::MapLoadError::StyleLoadError: + code = MGLErrorCodeLoadStyleFailed; + description = NSLocalizedStringWithDefaultValue(@"LOAD_STYLE_FAILED_DESC", nil, nil, @"The map failed to load because the style can't be loaded.", @"User-friendly error description"); + break; + case mbgl::MapLoadError::NotFoundError: + code = MGLErrorCodeNotFound; + description = NSLocalizedStringWithDefaultValue(@"STYLE_NOT_FOUND_DESC", nil, nil, @"The map failed to load because the style can’t be found or is incompatible.", @"User-friendly error description"); + break; + default: + code = MGLErrorCodeUnknown; + description = NSLocalizedStringWithDefaultValue(@"LOAD_MAP_FAILED_DESC", nil, nil, @"The map failed to load because an unknown error occurred.", @"User-friendly error description"); } NSDictionary *userInfo = @{ NSLocalizedDescriptionKey: description, - NSLocalizedFailureReasonErrorKey: @(mbgl::util::toString(exception).c_str()), + NSLocalizedFailureReasonErrorKey: @(what.c_str()), }; NSError *error = [NSError errorWithDomain:MGLErrorDomain code:code userInfo:userInfo]; [nativeView mapViewDidFailLoadingMapWithError:error]; |