diff --git a/editor/server_api.cpp b/editor/server_api.cpp index 41693c1cf..2cf0f5629 100644 --- a/editor/server_api.cpp +++ b/editor/server_api.cpp @@ -151,25 +151,33 @@ bool ServerApi06::TestOSMUser(std::string const & userName) UserPreferences ServerApi06::GetUserPreferences() const { - OsmOAuth::Response const response = m_auth.Request("/user/details"); - if (response.first != OsmOAuth::HTTP::OK) - MYTHROW(CantGetUserPreferences, (response)); + try { + OsmOAuth::Response const response = m_auth.Request("/user/details"); + if (response.first != OsmOAuth::HTTP::OK) + MYTHROW(CantGetUserPreferences, (response)); - pugi::xml_document details; - if (!details.load_string(response.second.c_str())) - MYTHROW(CantParseUserPreferences, (response)); + pugi::xml_document details; + if (!details.load_string(response.second.c_str())) + MYTHROW(CantParseUserPreferences, (response)); - pugi::xml_node const user = details.child("osm").child("user"); - if (!user || !user.attribute("id")) - MYTHROW(CantParseUserPreferences, ("No or 'id' attribute", response)); + pugi::xml_node const user = details.child("osm").child("user"); + if (!user || !user.attribute("id")) + MYTHROW(CantParseUserPreferences, ("No or 'id' attribute", response)); - UserPreferences pref; - pref.m_id = user.attribute("id").as_ullong(); - pref.m_displayName = user.attribute("display_name").as_string(); - pref.m_accountCreated = base::StringToTimestamp(user.attribute("account_created").as_string()); - pref.m_imageUrl = user.child("img").attribute("href").as_string(); - pref.m_changesets = user.child("changesets").attribute("count").as_uint(); - return pref; + UserPreferences pref; + pref.m_id = user.attribute("id").as_ullong(); + pref.m_displayName = user.attribute("display_name").as_string(); + pref.m_accountCreated = base::StringToTimestamp(user.attribute("account_created").as_string()); + pref.m_imageUrl = user.child("img").attribute("href").as_string(); + pref.m_changesets = user.child("changesets").attribute("count").as_uint(); + return pref; + } + catch (std::exception const & e) + { + LOG(LWARNING, ("Can't load user preferences from server: ", e.what())); + } + + return {}; } OsmOAuth::Response ServerApi06::GetXmlFeaturesInRect(double minLat, double minLon, double maxLat, double maxLon) const diff --git a/editor/server_api.hpp b/editor/server_api.hpp index 605c8b2f5..485d32e88 100644 --- a/editor/server_api.hpp +++ b/editor/server_api.hpp @@ -50,7 +50,6 @@ public: /// @returns true if user have registered/signed up even if his email address was not confirmed yet. bool TestOSMUser(std::string const & userName); /// Get OSM user preferences in a convenient struct. - /// Throws in case of any error. UserPreferences GetUserPreferences() const; /// Please use at least created_by=* and comment=* tags. /// @returns created changeset ID.