[ios] Standardize exception definitions

This commit is contained in:
Jason Wray
2018-08-09 13:35:28 -04:00
committed by GitHub
parent a378d6fc9b
commit ec7b920603
27 changed files with 105 additions and 52 deletions

View File

@@ -32,6 +32,8 @@ FOUNDATION_EXTERN MGL_EXPORT const MGLShapeSourceOption MGLShapeSourceOptionWrap
*/
FOUNDATION_EXTERN MGL_EXPORT const MGLShapeSourceOption MGLShapeSourceOptionClipsCoordinates;
FOUNDATION_EXTERN MGL_EXPORT MGLExceptionName const MGLInvalidDatasourceException;
/**
Data source for `MGLComputedShapeSource`. This protocol defines two optional methods for fetching
data, one based on tile coordinates, and one based on a bounding box. Classes that implement this

View File

@@ -10,6 +10,8 @@
#include <mbgl/tile/tile_id.hpp>
#include <mbgl/util/geojson.hpp>
const MGLExceptionName MGLInvalidDatasourceException = @"MGLInvalidDatasourceException";
const MGLShapeSourceOption MGLShapeSourceOptionWrapsCoordinates = @"MGLShapeSourceOptionWrapsCoordinates";
const MGLShapeSourceOption MGLShapeSourceOptionClipsCoordinates = @"MGLShapeSourceOptionClipsCoordinates";
@@ -205,10 +207,12 @@ mbgl::style::CustomGeometrySource::Options MBGLCustomGeometrySourceOptionsFromDi
self.dataSourceImplementsFeaturesForTile = [dataSource respondsToSelector:@selector(featuresInTileAtX:y:zoomLevel:)];
self.dataSourceImplementsFeaturesForBounds = [dataSource respondsToSelector:@selector(featuresInCoordinateBounds:zoomLevel:)];
if(!self.dataSourceImplementsFeaturesForBounds && !self.dataSourceImplementsFeaturesForTile) {
[NSException raise:@"Invalid Datasource" format:@"Datasource does not implement any MGLComputedShapeSourceDataSource methods"];
} else if(self.dataSourceImplementsFeaturesForBounds && self.dataSourceImplementsFeaturesForTile) {
[NSException raise:@"Invalid Datasource" format:@"Datasource implements multiple MGLComputedShapeSourceDataSource methods"];
if (!self.dataSourceImplementsFeaturesForBounds && !self.dataSourceImplementsFeaturesForTile) {
[NSException raise:MGLInvalidDatasourceException
format:@"Datasource does not implement any MGLComputedShapeSourceDataSource methods"];
} else if (self.dataSourceImplementsFeaturesForBounds && self.dataSourceImplementsFeaturesForTile) {
[NSException raise:MGLInvalidDatasourceException
format:@"Datasource implements multiple MGLComputedShapeSourceDataSource methods"];
}
_dataSource = dataSource;

View File

@@ -3,7 +3,7 @@
@implementation MGLForegroundStyleLayer
- (NSString *)sourceIdentifier {
[NSException raise:@"MGLAbstractClassException"
[NSException raise:MGLAbstractClassException
format:@"MGLForegroundStyleLayer is an abstract class"];
return nil;
}

View File

@@ -1,10 +1,13 @@
#import <Foundation/Foundation.h>
#import "MGLFoundation.h"
#import "MGLTypes.h"
#import "MGLOfflineRegion.h"
NS_ASSUME_NONNULL_BEGIN
FOUNDATION_EXTERN MGL_EXPORT MGLExceptionName const MGLInvalidOfflinePackException;
/**
The state an offline pack is currently in.
*/

View File

@@ -8,6 +8,8 @@
#include <mbgl/storage/default_file_source.hpp>
const MGLExceptionName MGLInvalidOfflinePackException = @"MGLInvalidOfflinePackException";
/**
Assert that the current offline pack is valid.
@@ -17,7 +19,7 @@
#define MGLAssertOfflinePackIsValid() \
do { \
if (_state == MGLOfflinePackStateInvalid) { \
[NSException raise:@"Invalid offline pack" \
[NSException raise:MGLInvalidOfflinePackException \
format: \
@"-[MGLOfflineStorage removePack:withCompletionHandler:] has been called " \
@"on this instance of MGLOfflinePack, rendering it invalid. It is an " \

View File

@@ -105,6 +105,8 @@ FOUNDATION_EXTERN MGL_EXPORT const MGLOfflinePackUserInfoKey MGLOfflinePackUserI
FOUNDATION_EXTERN MGL_EXPORT NSString * const MGLOfflinePackMaximumCountUserInfoKey __attribute__((unavailable("Use MGLOfflinePackUserInfoKeyMaximumCount")));
FOUNDATION_EXTERN MGL_EXPORT MGLExceptionName const MGLUnsupportedRegionTypeException;
/**
A block to be called once an offline pack has been completely created and
added.

View File

@@ -30,6 +30,8 @@ const MGLOfflinePackUserInfoKey MGLOfflinePackUserInfoKeyProgress = @"Progress";
const MGLOfflinePackUserInfoKey MGLOfflinePackUserInfoKeyError = @"Error";
const MGLOfflinePackUserInfoKey MGLOfflinePackUserInfoKeyMaximumCount = @"MaximumCount";
const MGLExceptionName MGLUnsupportedRegionTypeException = @"MGLUnsupportedRegionTypeException";
@interface MGLOfflineStorage ()
@property (nonatomic, strong, readwrite) NSMutableArray<MGLOfflinePack *> *packs;
@@ -278,8 +280,8 @@ const MGLOfflinePackUserInfoKey MGLOfflinePackUserInfoKeyMaximumCount = @"Maximu
- (void)_addPackForRegion:(id <MGLOfflineRegion>)region withContext:(NSData *)context completionHandler:(MGLOfflinePackAdditionCompletionHandler)completion {
if (![region conformsToProtocol:@protocol(MGLOfflineRegion_Private)]) {
[NSException raise:@"Unsupported region type" format:
@"Regions of type %@ are unsupported.", NSStringFromClass([region class])];
[NSException raise:MGLUnsupportedRegionTypeException
format:@"Regions of type %@ are unsupported.", NSStringFromClass([region class])];
return;
}

View File

@@ -40,7 +40,7 @@ bool operator==(const CLLocationCoordinate2D lhs, const CLLocationCoordinate2D r
}
- (mbgl::Geometry<double>)geometryObject {
[NSException raise:@"MGLAbstractClassException"
[NSException raise:MGLAbstractClassException
format:@"MGLShape is an abstract class"];
return mbgl::Point<double>();
}
@@ -103,9 +103,8 @@ bool operator==(const CLLocationCoordinate2D lhs, const CLLocationCoordinate2D r
- (CLLocationCoordinate2D)coordinate
{
[[NSException exceptionWithName:@"MGLAbstractClassException"
reason:@"MGLShape is an abstract class"
userInfo:nil] raise];
[NSException raise:MGLAbstractClassException
format:@"MGLShape is an abstract class"];
return kCLLocationCoordinate2DInvalid;
}

View File

@@ -48,7 +48,7 @@
- (void)addToMapView:(MGLMapView *)mapView {
if (_pendingSource == nullptr) {
[NSException raise:@"MGLRedundantSourceException"
[NSException raise:MGLRedundantSourceException
format:@"This instance %@ was already added to %@. Adding the same source instance " \
"to the style more than once is invalid.", self, mapView.style];
}

View File

@@ -31,6 +31,12 @@ NS_ASSUME_NONNULL_BEGIN
*/
static MGL_EXPORT const NSInteger MGLStyleDefaultVersion = 10;
FOUNDATION_EXTERN MGL_EXPORT MGLExceptionName const MGLInvalidStyleURLException;
FOUNDATION_EXTERN MGL_EXPORT MGLExceptionName const MGLRedundantLayerException;
FOUNDATION_EXTERN MGL_EXPORT MGLExceptionName const MGLRedundantLayerIdentifierException;
FOUNDATION_EXTERN MGL_EXPORT MGLExceptionName const MGLRedundantSourceException;
FOUNDATION_EXTERN MGL_EXPORT MGLExceptionName const MGLRedundantSourceIdentifierException;
/**
The proxy object for the current map style.

View File

@@ -55,6 +55,12 @@
#import "NSImage+MGLAdditions.h"
#endif
const MGLExceptionName MGLInvalidStyleURLException = @"MGLInvalidStyleURLException";
const MGLExceptionName MGLRedundantLayerException = @"MGLRedundantLayerException";
const MGLExceptionName MGLRedundantLayerIdentifierException = @"MGLRedundantLayerIdentifierException";
const MGLExceptionName MGLRedundantSourceException = @"MGLRedundantSourceException";
const MGLExceptionName MGLRedundantSourceIdentifierException = @"MGLRedundantSourceIdentifierException";
/**
Model class for localization changes.
*/
@@ -210,7 +216,7 @@ static_assert(6 == mbgl::util::default_styles::numOrderedStyles,
try {
[source addToMapView:self.mapView];
} catch (std::runtime_error & err) {
[NSException raise:@"MGLRedundantSourceIdentifierException" format:@"%s", err.what()];
[NSException raise:MGLRedundantSourceIdentifierException format:@"%s", err.what()];
}
}
@@ -313,14 +319,14 @@ static_assert(6 == mbgl::util::default_styles::numOrderedStyles,
MGLStyleLayer *sibling = layers.size() ? [self layerFromMBGLLayer:layers.at(0)] : nil;
[styleLayer addToStyle:self belowLayer:sibling];
} catch (const std::runtime_error & err) {
[NSException raise:@"MGLRedundantLayerIdentifierException" format:@"%s", err.what()];
[NSException raise:MGLRedundantLayerIdentifierException format:@"%s", err.what()];
}
} else {
try {
MGLStyleLayer *sibling = [self layerFromMBGLLayer:layers.at(index)];
[styleLayer addToStyle:self belowLayer:sibling];
} catch (std::runtime_error & err) {
[NSException raise:@"MGLRedundantLayerIdentifierException" format:@"%s", err.what()];
[NSException raise:MGLRedundantLayerIdentifierException format:@"%s", err.what()];
}
}
}
@@ -402,7 +408,7 @@ static_assert(6 == mbgl::util::default_styles::numOrderedStyles,
try {
[layer addToStyle:self belowLayer:nil];
} catch (std::runtime_error & err) {
[NSException raise:@"MGLRedundantLayerIdentifierException" format:@"%s", err.what()];
[NSException raise:MGLRedundantLayerIdentifierException format:@"%s", err.what()];
}
[self didChangeValueForKey:@"layers"];
}
@@ -431,7 +437,7 @@ static_assert(6 == mbgl::util::default_styles::numOrderedStyles,
try {
[layer addToStyle:self belowLayer:sibling];
} catch (std::runtime_error & err) {
[NSException raise:@"MGLRedundantLayerIdentifierException" format:@"%s", err.what()];
[NSException raise:MGLRedundantLayerIdentifierException format:@"%s", err.what()];
}
[self didChangeValueForKey:@"layers"];
}
@@ -473,14 +479,14 @@ static_assert(6 == mbgl::util::default_styles::numOrderedStyles,
try {
[layer addToStyle:self belowLayer:nil];
} catch (std::runtime_error & err) {
[NSException raise:@"MGLRedundantLayerIdentifierException" format:@"%s", err.what()];
[NSException raise:MGLRedundantLayerIdentifierException format:@"%s", err.what()];
}
} else {
MGLStyleLayer *sibling = [self layerFromMBGLLayer:layers.at(index + 1)];
try {
[layer addToStyle:self belowLayer:sibling];
} catch (std::runtime_error & err) {
[NSException raise:@"MGLRedundantLayerIdentifierException" format:@"%s", err.what()];
[NSException raise:MGLRedundantLayerIdentifierException format:@"%s", err.what()];
}
}
[self didChangeValueForKey:@"layers"];

View File

@@ -5,6 +5,8 @@
NS_ASSUME_NONNULL_BEGIN
FOUNDATION_EXTERN MGL_EXPORT MGLExceptionName const MGLInvalidStyleLayerException;
/**
`MGLStyleLayer` is an abstract base class for style layers. A style layer
manages the layout and appearance of content at a specific z-index in a style.

View File

@@ -4,6 +4,8 @@
#include <mbgl/style/style.hpp>
#include <mbgl/style/layer.hpp>
const MGLExceptionName MGLInvalidStyleLayerException = @"MGLInvalidStyleLayerException";
@interface MGLStyleLayer ()
@property (nonatomic, readonly) mbgl::style::Layer *rawLayer;
@@ -33,7 +35,7 @@
- (void)addToStyle:(MGLStyle *)style belowLayer:(MGLStyleLayer *)otherLayer
{
if (_pendingLayer == nullptr) {
[NSException raise:@"MGLRedundantLayerException"
[NSException raise:MGLRedundantLayerException
format:@"This instance %@ was already added to %@. Adding the same layer instance " \
"to the style more than once is invalid.", self, style];
}

View File

@@ -24,7 +24,7 @@ struct LayerWrapper {
#define MGLAssertStyleLayerIsValid() \
do { \
if (!self.rawLayer) { \
[NSException raise:@"Invalid style layer" \
[NSException raise:MGLInvalidStyleLayerException \
format: \
@"-[MGLStyle removeLayer:] has been called " \
@"with this instance but another style layer instance was added with the same identifer. It is an " \

View File

@@ -23,8 +23,7 @@
}
- (instancetype)init {
[NSException raise:@"Method unavailable"
format:
[NSException raise:NSGenericException format:
@"-[MGLTilePyramidOfflineRegion init] is unavailable. "
@"Use -initWithStyleURL:bounds:fromZoomLevel:toZoomLevel: instead."];
return nil;
@@ -37,7 +36,7 @@
}
if (!styleURL.scheme) {
[NSException raise:@"Invalid style URL" format:
[NSException raise:MGLInvalidStyleURLException format:
@"%@ does not support setting a relative file URL as the style URL. "
@"To download the online resources required by this style, "
@"specify a URL to an online copy of this style. "

View File

@@ -25,7 +25,7 @@ const MGLTileSourceOption MGLTileSourceOptionDEMEncoding = @"MGLTileSourceOption
@implementation MGLTileSource
- (NSURL *)configurationURL {
[NSException raise:@"MGLAbstractClassException"
[NSException raise:MGLAbstractClassException
format:@"MGLTileSource is an abstract class"];
return nil;
}
@@ -41,7 +41,7 @@ const MGLTileSourceOption MGLTileSourceOptionDEMEncoding = @"MGLTileSourceOption
}
- (NSString *)attributionHTMLString {
[NSException raise:@"MGLAbstractClassException"
[NSException raise:MGLAbstractClassException
format:@"MGLTileSource is an abstract class"];
return nil;
}

View File

@@ -30,6 +30,14 @@ NS_ASSUME_NONNULL_BEGIN
typedef NSString *NSNotificationName;
#endif
typedef NSString *MGLExceptionName NS_TYPED_EXTENSIBLE_ENUM;
/**
:nodoc: Generic exceptions used across multiple disparate classes. Exceptions
that are unique to a class or class-cluster should be defined in those headers.
*/
FOUNDATION_EXTERN MGL_EXPORT MGLExceptionName const MGLAbstractClassException;
/** Indicates an error occurred in the Mapbox SDK. */
FOUNDATION_EXTERN MGL_EXPORT NSErrorDomain const MGLErrorDomain;

View File

@@ -1,3 +1,5 @@
#import "MGLTypes.h"
const MGLExceptionName MGLAbstractClassException = @"MGLAbstractClassException";
NSString * const MGLErrorDomain = @"MGLErrorDomain";

View File

@@ -3,12 +3,12 @@
@implementation MGLVectorStyleLayer
- (void)setPredicate:(NSPredicate *)predicate {
[NSException raise:@"MGLAbstractClassException"
[NSException raise:MGLAbstractClassException
format:@"MGLVectorStyleLayer is an abstract class"];
}
- (NSPredicate *)predicate {
[NSException raise:@"MGLAbstractClassException"
[NSException raise:MGLAbstractClassException
format:@"MGLVectorStyleLayer is an abstract class"];
return nil;
}

View File

@@ -27,6 +27,8 @@ NS_ASSUME_NONNULL_BEGIN
#define NSLocalizedStringWithDefaultValue(key, tbl, bundle, val, comment) \
[[NSBundle mgl_frameworkBundle] localizedStringForKey:(key) value:(val) table:(tbl)]
FOUNDATION_EXTERN MGL_EXPORT MGLExceptionName const MGLBundleNotFoundException;
@interface NSBundle (MGLAdditions)
/// Returns the bundle containing the SDK’s classes and Info.plist file.

View File

@@ -2,6 +2,8 @@
#import "MGLAccountManager.h"
const MGLExceptionName MGLBundleNotFoundException = @"MGLBundleNotFoundException";
@implementation NSBundle (MGLAdditions)
+ (instancetype)mgl_frameworkBundle {
@@ -14,8 +16,8 @@
if (bundlePath) {
bundle = [self bundleWithPath:bundlePath];
} else {
[NSException raise:@"MGLBundleNotFoundException" format:
@"The Mapbox framework bundle could not be found. If using the Mapbox Maps SDK for iOS as a static framework, make sure that Mapbox.bundle is copied into the root of the app bundle."];
[NSException raise:MGLBundleNotFoundException
format:@"The Mapbox framework bundle could not be found. If using the Mapbox Maps SDK for iOS as a static framework, make sure that Mapbox.bundle is copied into the root of the app bundle."];
}
}

View File

@@ -12,10 +12,10 @@
XCTAssertEqual(invalidPack.state, MGLOfflinePackStateInvalid, @"Offline pack should be invalid when initialized independently of MGLOfflineStorage.");
XCTAssertThrowsSpecificNamed(invalidPack.region, NSException, @"Invalid offline pack", @"Invalid offline pack should raise an exception when accessing its region.");
XCTAssertThrowsSpecificNamed(invalidPack.context, NSException, @"Invalid offline pack", @"Invalid offline pack should raise an exception when accessing its context.");
XCTAssertThrowsSpecificNamed([invalidPack resume], NSException, @"Invalid offline pack", @"Invalid offline pack should raise an exception when being resumed.");
XCTAssertThrowsSpecificNamed([invalidPack suspend], NSException, @"Invalid offline pack", @"Invalid offline pack should raise an exception when being suspended.");
XCTAssertThrowsSpecificNamed(invalidPack.region, NSException, MGLInvalidOfflinePackException, @"Invalid offline pack should raise an exception when accessing its region.");
XCTAssertThrowsSpecificNamed(invalidPack.context, NSException, MGLInvalidOfflinePackException, @"Invalid offline pack should raise an exception when accessing its context.");
XCTAssertThrowsSpecificNamed([invalidPack resume], NSException, MGLInvalidOfflinePackException, @"Invalid offline pack should raise an exception when being resumed.");
XCTAssertThrowsSpecificNamed([invalidPack suspend], NSException, MGLInvalidOfflinePackException, @"Invalid offline pack should raise an exception when being suspended.");
}
- (void)testProgressBoxing {

View File

@@ -14,7 +14,7 @@
XCTAssertEqualObjects(region.styleURL, [MGLStyle streetsStyleURLWithVersion:MGLStyleDefaultVersion], @"Streets isn’t the default style.");
NSURL *localURL = [NSURL URLWithString:@"beautiful.style"];
XCTAssertThrowsSpecificNamed([[MGLTilePyramidOfflineRegion alloc] initWithStyleURL:localURL bounds:bounds fromZoomLevel:0 toZoomLevel:DBL_MAX], NSException, @"Invalid style URL", @"No exception raised when initializing region with a local file URL as the style URL.");
XCTAssertThrowsSpecificNamed([[MGLTilePyramidOfflineRegion alloc] initWithStyleURL:localURL bounds:bounds fromZoomLevel:0 toZoomLevel:DBL_MAX], NSException, MGLInvalidStyleURLException, @"No exception raised when initializing region with a local file URL as the style URL.");
}
- (void)testEquality {

View File

@@ -156,15 +156,15 @@
- (void)testAddingSourcesTwice {
MGLShapeSource *shapeSource = [[MGLShapeSource alloc] initWithIdentifier:@"shapeSource" shape:nil options:nil];
[self.style addSource:shapeSource];
XCTAssertThrowsSpecificNamed([self.style addSource:shapeSource], NSException, @"MGLRedundantSourceException");
XCTAssertThrowsSpecificNamed([self.style addSource:shapeSource], NSException, MGLRedundantSourceException);
MGLRasterTileSource *rasterTileSource = [[MGLRasterTileSource alloc] initWithIdentifier:@"rasterTileSource" configurationURL:[NSURL URLWithString:@".json"] tileSize:42];
[self.style addSource:rasterTileSource];
XCTAssertThrowsSpecificNamed([self.style addSource:rasterTileSource], NSException, @"MGLRedundantSourceException");
XCTAssertThrowsSpecificNamed([self.style addSource:rasterTileSource], NSException, MGLRedundantSourceException);
MGLVectorTileSource *vectorTileSource = [[MGLVectorTileSource alloc] initWithIdentifier:@"vectorTileSource" configurationURL:[NSURL URLWithString:@".json"]];
[self.style addSource:vectorTileSource];
XCTAssertThrowsSpecificNamed([self.style addSource:vectorTileSource], NSException, @"MGLRedundantSourceException");
XCTAssertThrowsSpecificNamed([self.style addSource:vectorTileSource], NSException, MGLRedundantSourceException);
}
- (void)testAddingSourcesWithDuplicateIdentifiers {
@@ -172,7 +172,7 @@
MGLVectorTileSource *source2 = [[MGLVectorTileSource alloc] initWithIdentifier:@"my-source" configurationURL:[NSURL URLWithString:@"mapbox://mapbox.mapbox-terrain-v2"]];
[self.style addSource: source1];
XCTAssertThrowsSpecificNamed([self.style addSource: source2], NSException, @"MGLRedundantSourceIdentifierException");
XCTAssertThrowsSpecificNamed([self.style addSource: source2], NSException, MGLRedundantSourceIdentifierException);
}
- (void)testRemovingSourcesBeforeAddingThem {
@@ -265,27 +265,27 @@
MGLBackgroundStyleLayer *backgroundLayer = [[MGLBackgroundStyleLayer alloc] initWithIdentifier:@"backgroundLayer"];
[self.style addLayer:backgroundLayer];
XCTAssertThrowsSpecificNamed([self.style addLayer:backgroundLayer], NSException, @"MGLRedundantLayerException");
XCTAssertThrowsSpecificNamed([self.style addLayer:backgroundLayer], NSException, MGLRedundantLayerException);
MGLCircleStyleLayer *circleLayer = [[MGLCircleStyleLayer alloc] initWithIdentifier:@"circleLayer" source:source];
[self.style addLayer:circleLayer];
XCTAssertThrowsSpecificNamed([self.style addLayer:circleLayer], NSException, @"MGLRedundantLayerException");
XCTAssertThrowsSpecificNamed([self.style addLayer:circleLayer], NSException, MGLRedundantLayerException);
MGLFillStyleLayer *fillLayer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"fillLayer" source:source];
[self.style addLayer:fillLayer];
XCTAssertThrowsSpecificNamed([self.style addLayer:fillLayer], NSException, @"MGLRedundantLayerException");
XCTAssertThrowsSpecificNamed([self.style addLayer:fillLayer], NSException, MGLRedundantLayerException);
MGLLineStyleLayer *lineLayer = [[MGLLineStyleLayer alloc] initWithIdentifier:@"lineLayer" source:source];
[self.style addLayer:lineLayer];
XCTAssertThrowsSpecificNamed([self.style addLayer:lineLayer], NSException, @"MGLRedundantLayerException");
XCTAssertThrowsSpecificNamed([self.style addLayer:lineLayer], NSException, MGLRedundantLayerException);
MGLRasterStyleLayer *rasterLayer = [[MGLRasterStyleLayer alloc] initWithIdentifier:@"rasterLayer" source:source];
[self.style addLayer:rasterLayer];
XCTAssertThrowsSpecificNamed([self.style addLayer:rasterLayer], NSException, @"MGLRedundantLayerException");
XCTAssertThrowsSpecificNamed([self.style addLayer:rasterLayer], NSException, MGLRedundantLayerException);
MGLSymbolStyleLayer *symbolLayer = [[MGLSymbolStyleLayer alloc] initWithIdentifier:@"symbolLayer" source:source];
[self.style addLayer:symbolLayer];
XCTAssertThrowsSpecificNamed([self.style addLayer:symbolLayer], NSException, @"MGLRedundantLayerException");
XCTAssertThrowsSpecificNamed([self.style addLayer:symbolLayer], NSException, MGLRedundantLayerException);
}
- (void)testAddingLayersWithDuplicateIdentifiers {

View File

@@ -5,6 +5,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
## master
* Improved the Swift interface for `MGLMapView.decelerationRate`. ([#12584](https://github.com/mapbox/mapbox-gl-native/issues/12584))
* Fixed inconsistencies in exception naming. ([#12583](https://github.com/mapbox/mapbox-gl-native/issues/12583))
## 4.3.0

View File

@@ -97,6 +97,10 @@ FOUNDATION_EXTERN MGL_EXPORT const MGLMapViewPreferredFramesPerSecond MGLMapView
/** The maximum supported frame rate; typically 60 FPS. */
FOUNDATION_EXTERN MGL_EXPORT const MGLMapViewPreferredFramesPerSecond MGLMapViewPreferredFramesPerSecondMaximum;
FOUNDATION_EXTERN MGL_EXPORT MGLExceptionName const MGLMissingLocationServicesUsageDescriptionException;
FOUNDATION_EXTERN MGL_EXPORT MGLExceptionName const MGLUserLocationAnnotationTypeException;
FOUNDATION_EXTERN MGL_EXPORT MGLExceptionName const MGLResourceNotFoundException;
/**
An interactive, customizable map view with an interface similar to the one
provided by Apple’s MapKit.

View File

@@ -92,6 +92,10 @@ const MGLMapViewPreferredFramesPerSecond MGLMapViewPreferredFramesPerSecondDefau
const MGLMapViewPreferredFramesPerSecond MGLMapViewPreferredFramesPerSecondLowPower = 30;
const MGLMapViewPreferredFramesPerSecond MGLMapViewPreferredFramesPerSecondMaximum = 60;
const MGLExceptionName MGLMissingLocationServicesUsageDescriptionException = @"MGLMissingLocationServicesUsageDescriptionException";
const MGLExceptionName MGLUserLocationAnnotationTypeException = @"MGLUserLocationAnnotationTypeException";
const MGLExceptionName MGLResourceNotFoundException = @"MGLResourceNotFoundException";
/// Indicates the manner in which the map view is tracking the user location.
typedef NS_ENUM(NSUInteger, MGLUserTrackingState) {
/// The map view is not yet tracking the user location.
@@ -138,7 +142,7 @@ static NSString * const MGLInvisibleStyleMarkerSymbolName = @"invisible_marker";
/// Prefix that denotes a sprite installed by MGLMapView, to avoid collisions
/// with style-defined sprites.
NSString *const MGLAnnotationSpritePrefix = @"com.mapbox.sprites.";
NSString * const MGLAnnotationSpritePrefix = @"com.mapbox.sprites.";
/// Slop area around the hit testing point, allowing for imprecise annotation selection.
const CGFloat MGLAnnotationImagePaddingForHitTest = 5;
@@ -4790,7 +4794,8 @@ public:
NSString *suggestedUsageKeys = requiresWhenInUseUsageDescription ?
@"NSLocationWhenInUseUsageDescription and (optionally) NSLocationAlwaysAndWhenInUseUsageDescription" :
@"NSLocationWhenInUseUsageDescription and/or NSLocationAlwaysUsageDescription";
[NSException raise:@"Missing Location Services usage description" format:@"This app must have a value for %@ in its Info.plist.", suggestedUsageKeys];
[NSException raise:MGLMissingLocationServicesUsageDescriptionException
format:@"This app must have a value for %@ in its Info.plist.", suggestedUsageKeys];
}
}
@@ -4827,7 +4832,7 @@ public:
userLocationAnnotationView = (MGLUserLocationAnnotationView *)[self.delegate mapView:self viewForAnnotation:self.userLocation];
if (userLocationAnnotationView && ! [userLocationAnnotationView isKindOfClass:MGLUserLocationAnnotationView.class])
{
[NSException raise:@"MGLUserLocationAnnotationTypeException"
[NSException raise:MGLUserLocationAnnotationTypeException
format:@"User location annotation view must be a kind of MGLUserLocationAnnotationView. %@", userLocationAnnotationView.debugDescription];
}
}
@@ -6007,7 +6012,7 @@ public:
if ( ! image)
{
[NSException raise:@"MGLResourceNotFoundException" format:
[NSException raise:MGLResourceNotFoundException format:
@"The resource named “%@” could not be found in the Mapbox framework bundle.", imageName];
}
@@ -6296,8 +6301,8 @@ private:
NSURL *url = URLString.length ? [NSURL URLWithString:URLString] : nil;
if (URLString.length && !url)
{
[NSException raise:@"Invalid style URL" format:
@"“%@” is not a valid style URL.", URLString];
[NSException raise:MGLInvalidStyleURLException
format:@"“%@” is not a valid style URL.", URLString];
}
self.styleURL = url;
}