summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Shalamov <alexander.shalamov@mapbox.com>2018-10-09 17:17:12 +0300
committerAlexander Shalamov <alexander.shalamov@mapbox.com>2018-12-17 11:37:56 +0200
commitf076a1fe39a466f9be91934e35ed179e45edece0 (patch)
treef1471f11010951831069c472c6268e125db1bdbf
parentfed201aaedc1b1c86d6a3bb3a10894fc46cf5628 (diff)
downloadqtlocation-mapboxgl-f076a1fe39a466f9be91934e35ed179e45edece0.tar.gz
[core] Use util::readFile for Local and Asset file sources
Use exception free util::readFile instead of util::read_file for LocalFileSource and AssetFileSource implementations.
-rw-r--r--platform/default/src/mbgl/storage/asset_file_source.cpp9
-rw-r--r--platform/default/src/mbgl/storage/local_file_source.cpp9
2 files changed, 10 insertions, 8 deletions
diff --git a/platform/default/src/mbgl/storage/asset_file_source.cpp b/platform/default/src/mbgl/storage/asset_file_source.cpp
index 7988654ae5..ed446f85a5 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>(Response::Error::Reason::NotFound);
} else {
- try {
- response.data = std::make_shared<std::string>(util::read_file(path));
- } catch (...) {
+ auto data = util::readFile(path);
+ if (!data) {
response.error = std::make_unique<Response::Error>(
Response::Error::Reason::Other,
- util::toString(std::current_exception()));
+ std::string("Cannot read file ") + path);
+ } else {
+ response.data = std::make_shared<std::string>(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 1b7b7b9278..1bc52fb419 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>(Response::Error::Reason::NotFound);
} else {
- try {
- response.data = std::make_shared<std::string>(util::read_file(path));
- } catch (...) {
+ auto data = util::readFile(path);
+ if (!data) {
response.error = std::make_unique<Response::Error>(
Response::Error::Reason::Other,
- util::toString(std::current_exception()));
+ std::string("Cannot read file ") + path);
+ } else {
+ response.data = std::make_shared<std::string>(std::move(*data));
}
}