[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:
@@ -2,6 +2,7 @@
|
||||
#include <mbgl/map/map_impl.hpp>
|
||||
#include <mbgl/renderer/update_parameters.hpp>
|
||||
#include <mbgl/style/style_impl.hpp>
|
||||
#include <mbgl/util/exception.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -97,7 +98,26 @@ void Map::Impl::onStyleLoaded() {
|
||||
}
|
||||
|
||||
void Map::Impl::onStyleError(std::exception_ptr error) {
|
||||
observer.onDidFailLoadingMap(error);
|
||||
MapLoadError type;
|
||||
std::string description;
|
||||
|
||||
try {
|
||||
std::rethrow_exception(error);
|
||||
} catch (const mbgl::util::StyleParseException& e) {
|
||||
type = MapLoadError::StyleParseError;
|
||||
description = e.what();
|
||||
} catch (const mbgl::util::StyleLoadException& e) {
|
||||
type = MapLoadError::StyleLoadError;
|
||||
description = e.what();
|
||||
} catch (const mbgl::util::NotFoundException& e) {
|
||||
type = MapLoadError::NotFoundError;
|
||||
description = e.what();
|
||||
} catch (const std::exception& e) {
|
||||
type = MapLoadError::UnknownError;
|
||||
description = e.what();
|
||||
}
|
||||
|
||||
observer.onDidFailLoadingMap(type, description);
|
||||
}
|
||||
|
||||
#pragma mark - Map::Impl RendererObserver
|
||||
|
||||
Reference in New Issue
Block a user