diff options
author | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2018-10-09 17:17:12 +0300 |
---|---|---|
committer | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2018-12-14 18:34:01 +0200 |
commit | 197205e47989625be8e7f72ae0a4c77920760dbe (patch) | |
tree | 7d22351ceb8c5a280fd13593911c7de37619f3a4 | |
parent | 8b7725211eaddcb55e5043a02024736f57618bca (diff) | |
download | qtlocation-mapboxgl-197205e47989625be8e7f72ae0a4c77920760dbe.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.cpp | 9 | ||||
-rw-r--r-- | platform/default/src/mbgl/storage/local_file_source.cpp | 9 |
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)); } } |