Repository navigation
[ios] Standardize exception definitions - #12583
Conversation
julianrex
left a comment
There was a problem hiding this comment.
Great to see these changes!
The only comment I have is: should the exception names be of the form MGLException<Name>? So MGLExceptionAbstractClass instead of MGLAbstractClassException?
(This makes sense to me when I think of it in terms of calling our |
fabian-guerra
left a comment
There was a problem hiding this comment.
Instead of having a master header with all the exceptions, we will declare on each file the exceptions it throws (if any)? If so, should we document this?
|
@julianrex and I were curious about how this ended up looking in Swift, so: |
There was a problem hiding this comment.
I was copying NSExceptionName, but I’m going to look at replacing this with NS_TYPED_EXTENSIBLE_ENUM on Apple’s recommendation:
You might encounter Objective-C code that uses the older
NS_STRING_ENUMandNS_EXTENSIBLE_STRING_ENUMmacros, which were used to group string constants. UseNS_TYPED_ENUMandNS_TYPED_EXTENSIBLE_ENUMwhen grouping related constants of any type, including string constants.
There was a problem hiding this comment.
Xcode 9 has all of these defined as the same thing, so it’s just cosmetic:
#define NS_STRING_ENUM _NS_TYPED_ENUM
#define NS_EXTENSIBLE_STRING_ENUM _NS_TYPED_EXTENSIBLE_ENUM
#define NS_TYPED_ENUM _NS_TYPED_ENUM
#define NS_TYPED_EXTENSIBLE_ENUM _NS_TYPED_EXTENSIBLE_ENUM
... but let’s still standardize on the new one.
Defining non-generic constants close to their main usage sites is generally a good practice, I think, and is something we’ve been doing with other constants, like |
eae1570 to
2c18acb
Compare
| { | ||
| [NSException raise:@"Invalid style URL" format: | ||
| @"“%@” is not a valid style URL.", URLString]; | ||
| [NSException raise:MGLInvalidStyleURLException |
There was a problem hiding this comment.
#12640 takes care of the macOS side of this change.

Fixes #7258 by converting stringly-typed exception names into
MGLExceptionName-typed constants. This doesn’t attempt to document the exceptions, but that could happen in the future./cc @1ec5 @fabian-guerra @julianrex @captainbarbosa