Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorArsentiy Milchakov <a.milchakov@corp.mail.ru>2016-09-08 18:41:57 +0300
committerArsentiy Milchakov <a.milchakov@corp.mail.ru>2016-09-08 18:41:57 +0300
commit501515e8bc3bfda30321e0cf8ea5788e7409059c (patch)
treecb4f8822cfc9cb118e52bd8fb2fe7ccfe15323cd /editor
parent93baffbcb2681df9065c7e4bf758b9a7451524a1 (diff)
config loader exception handling
Diffstat (limited to 'editor')
-rw-r--r--editor/config_loader.cpp31
-rw-r--r--editor/config_loader.hpp2
2 files changed, 27 insertions, 6 deletions
diff --git a/editor/config_loader.cpp b/editor/config_loader.cpp
index 6063f93ce3..beada4f2f5 100644
--- a/editor/config_loader.cpp
+++ b/editor/config_loader.cpp
@@ -29,7 +29,15 @@ string GetHashFilePath() { return GetPlatform().WritablePathForFile(kHashFileNam
string RunSimpleHttpRequest(string const & url)
{
HTTPClientPlatformWrapper request(url);
- auto const result = request.RunHTTPRequest();
+ bool result = false;
+ try
+ {
+ result = request.RunHTTPRequest();
+ }
+ catch (runtime_error const & ex)
+ {
+ LOG(LWARNING, ("Exception from HTTPClientPlatformWrapper::RunHTTPRequest, message: ", ex.what()));
+ }
if (result && !request.was_redirected() && request.error_code() == 200) // 200 - http status OK
{
@@ -122,11 +130,26 @@ void ConfigLoader::ResetConfig(pugi::xml_document const & doc)
void ConfigLoader::LoadFromLocal(pugi::xml_document & doc)
{
string content;
- auto const reader = GetPlatform().GetReader(kConfigFileName);
- reader->ReadAsString(content);
+ unique_ptr<ModelReader> reader;
+
+ try
+ {
+ reader = GetPlatform().GetReader(kConfigFileName);
+ }
+ catch (RootException const & ex)
+ {
+ LOG(LERROR, (ex.Msg()));
+ return;
+ }
+
+ if (reader)
+ reader->ReadAsString(content);
if (!doc.load_buffer(content.data(), content.size()))
- MYTHROW(ConfigLoadError, ("Can't parse config"));
+ {
+ LOG(LERROR, ("Config can not be loaded."));
+ doc.reset();
+ }
}
// static
diff --git a/editor/config_loader.hpp b/editor/config_loader.hpp
index c9ede4a15a..0b445b22e0 100644
--- a/editor/config_loader.hpp
+++ b/editor/config_loader.hpp
@@ -44,8 +44,6 @@ private:
condition_variable m_event;
};
-DECLARE_EXCEPTION(ConfigLoadError, RootException);
-
// Class which loads config from local drive, checks hash
// for config on server and downloads new config if needed.
class ConfigLoader