diff --git a/platform/default/src/mbgl/storage/asset_file_source.cpp b/platform/default/src/mbgl/storage/asset_file_source.cpp index 7988654ae..ed446f85a 100644 --- a/platform/default/src/mbgl/storage/asset_file_source.cpp +++ b/platform/default/src/mbgl/storage/asset_file_source.cpp @@ -44,12 +44,13 @@ public: } else if (result == -1 && errno == ENOENT) { response.error = std::make_unique(Response::Error::Reason::NotFound); } else { - try { - response.data = std::make_shared(util::read_file(path)); - } catch (...) { + auto data = util::readFile(path); + if (!data) { response.error = std::make_unique( Response::Error::Reason::Other, - util::toString(std::current_exception())); + std::string("Cannot read file ") + path); + } else { + response.data = std::make_shared(std::move(*data)); } } diff --git a/platform/default/src/mbgl/storage/local_file_source.cpp b/platform/default/src/mbgl/storage/local_file_source.cpp index 1b7b7b927..1bc52fb41 100644 --- a/platform/default/src/mbgl/storage/local_file_source.cpp +++ b/platform/default/src/mbgl/storage/local_file_source.cpp @@ -46,12 +46,13 @@ public: } else if (result == -1 && errno == ENOENT) { response.error = std::make_unique(Response::Error::Reason::NotFound); } else { - try { - response.data = std::make_shared(util::read_file(path)); - } catch (...) { + auto data = util::readFile(path); + if (!data) { response.error = std::make_unique( Response::Error::Reason::Other, - util::toString(std::current_exception())); + std::string("Cannot read file ") + path); + } else { + response.data = std::make_shared(std::move(*data)); } }