From b0278ee8b412817233ae20b9edb6f7a641774c67 Mon Sep 17 00:00:00 2001 From: Christoph Sommer Date: Sun, 8 Apr 2007 12:02:51 +0000 Subject: [PATCH] Graceful handling of situations when downloading the Add-on list fails SVN-Revision: 4968 --- src/addon_manager.cpp | 2 ++ src/title.cpp | 39 +++++++++++++++++++++++++++------------ 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/addon_manager.cpp b/src/addon_manager.cpp index 8c1c1e463..959d97a06 100644 --- a/src/addon_manager.cpp +++ b/src/addon_manager.cpp @@ -157,6 +157,8 @@ AddonManager::get_available_addons() const curl_easy_perform(curl_handle); curl_easy_cleanup(curl_handle); + if (addoninfos == "") throw std::runtime_error("Add-on list download failed"); + try { lisp::Parser parser; std::stringstream addoninfos_stream(addoninfos); diff --git a/src/title.cpp b/src/title.cpp index 120935b6d..a990c69b2 100644 --- a/src/title.cpp +++ b/src/title.cpp @@ -296,10 +296,15 @@ TitleScreen::check_addons_menu() // check if "Check Online" was chosen if (index == 0) { - available_addons = AddonManager::get_instance().get_available_addons(); - generate_addons_menu(); - Menu::set_current(addons_menu.get()); - addons_menu->set_active_item(index); + try { + available_addons = AddonManager::get_instance().get_available_addons(); + generate_addons_menu(); + Menu::set_current(addons_menu.get()); + addons_menu->set_active_item(index); + } + catch (std::runtime_error e) { + log_warning << "Check for available Add-ons failed with error message \"" << e.what() << "\"" << std::endl; + } return; } @@ -307,15 +312,25 @@ TitleScreen::check_addons_menu() if ((index >= ADDON_LIST_START_ID) && (index < ADDON_LIST_START_ID) + addons.size()) { Addon addon = addons[index - ADDON_LIST_START_ID]; if (!addon.isInstalled) { - addon.install(); - generate_addons_menu(); - Menu::set_current(addons_menu.get()); - addons_menu->set_active_item(index); + try { + addon.install(); + generate_addons_menu(); + Menu::set_current(addons_menu.get()); + addons_menu->set_active_item(index); + } + catch (std::runtime_error e) { + log_warning << "Installation of Add-on failed with error message \"" << e.what() << "\"" << std::endl; + } } else { - addon.remove(); - generate_addons_menu(); - Menu::set_current(addons_menu.get()); - addons_menu->set_active_item(index); + try { + addon.remove(); + generate_addons_menu(); + Menu::set_current(addons_menu.get()); + addons_menu->set_active_item(index); + } + catch (std::runtime_error e) { + log_warning << "Removal of Add-on failed with error message \"" << e.what() << "\"" << std::endl; + } } } -- 2.11.0