-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[WIP] Throw/notify on map loading error #3063
Conversation
Throw an Objective-C exception whenever mbgl encounters an error. (Developers are trained to break on Objective-C exceptions as opposed to C++ exceptions.) If mbgl is unable to set up the map and the delegate implements the map loading failure callback method, call that method instead of throwing the exception. ref #2762
@@ -202,6 +203,9 @@ - (void)setStyleURL:(nullable NSURL *)styleURL | |||
- (void)commonInit | |||
{ | |||
_isTargetingInterfaceBuilder = NSProcessInfo.processInfo.mgl_isInterfaceBuilderDesignablesAgent; | |||
|
|||
std::unique_ptr<MGLLogObserver> logObserver = std::make_unique<MGLLogObserver>(self); | |||
mbgl::Log::setObserver(std::move(logObserver)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mbgl::Log
is a singleton, so this approach won’t scale to multiple MGLMapView
s.
I considered calling |
bool onRecord(mbgl::EventSeverity severity, mbgl::Event event, int64_t code, const std::string &msg) | ||
{ | ||
__block bool didNotifyDelegate = false; | ||
if (severity == mbgl::EventSeverity::Error && event == mbgl::Event::Setup) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How closely does mbgl::Event::Setup
correlate to map loading errors (as opposed to networking errors)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, it’s only used inside MapContext::setStyleURL()
, when the style itself fails to load due to a failed HTTP request. Is that consistent with what you outlined in #2775 (comment)?
Closing as stale. |
Throw an Objective-C exception whenever mbgl encounters an error. (Developers are trained to break on Objective-C exceptions as opposed to C++ exceptions.) If mbgl is unable to set up the map and the delegate implements the map loading failure callback method, call that method instead of throwing the exception.
/ref #2762, #2775
/cc @friedbunny @incanus