summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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));
}
}