[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:
Ander Conselvan de Oliveira
2019-02-22 09:31:21 +02:00
parent 565792606d
commit 7d19115720
11 changed files with 93 additions and 61 deletions

View File

@@ -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));