[core] Don't use exceptions in MapObserver::onDidFailLoadingMap
Using different exception pointers to specify the loading failure makes an awkward API. Most users rethrow the exception only to figure out what type of error happened so it can be reported properly. So replace the exception pointer with a enum an string description of the failure.
This commit is contained in:
@@ -164,13 +164,12 @@ void NativeMapView::onDidFinishLoadingMap() {
|
||||
}
|
||||
}
|
||||
|
||||
void NativeMapView::onDidFailLoadingMap(std::exception_ptr exceptionPtr) {
|
||||
void NativeMapView::onDidFailLoadingMap(MapLoadError, const std::string& error) {
|
||||
assert(vm != nullptr);
|
||||
|
||||
android::UniqueEnv _env = android::AttachEnv();
|
||||
static auto& javaClass = jni::Class<NativeMapView>::Singleton(*_env);
|
||||
static auto onDidFailLoadingMap = javaClass.GetMethod<void (jni::String)>(*_env, "onDidFailLoadingMap");
|
||||
std::string error = mbgl::util::toString(exceptionPtr);
|
||||
auto weakReference = javaPeer.get(*_env);
|
||||
if (weakReference) {
|
||||
weakReference.Call(*_env, onDidFailLoadingMap, jni::Make<jni::String>(*_env, error));
|
||||
|
||||
Reference in New Issue
Block a user