From 67758aad31ac90e46e9f6acd59b97aa608633f5c Mon Sep 17 00:00:00 2001 From: fgerlits Date: Tue, 22 Aug 2006 13:06:36 +0000 Subject: [PATCH] improved error reporting in the search window; this fixes #1763 --- .../gLiveSupport/src/SearchWindow.cxx | 64 +++++++++++++------ .../products/gLiveSupport/src/SearchWindow.h | 30 +++++++++ .../src/products/gLiveSupport/var/root.txt | 3 +- 3 files changed, 77 insertions(+), 20 deletions(-) diff --git a/livesupport/src/products/gLiveSupport/src/SearchWindow.cxx b/livesupport/src/products/gLiveSupport/src/SearchWindow.cxx index ea4d6b409..ac992439c 100644 --- a/livesupport/src/products/gLiveSupport/src/SearchWindow.cxx +++ b/livesupport/src/products/gLiveSupport/src/SearchWindow.cxx @@ -453,7 +453,7 @@ SearchWindow :: localSearch(Ptr::Ref criteria) try { searchResults = gLiveSupport->search(criteria); } catch (XmlRpcException &e) { - std::cerr << e.what() << std::endl; + displayLocalSearchError(e); return; } @@ -537,9 +537,7 @@ SearchWindow :: remoteSearchOpen(Ptr::Ref criteria) try { storage->cancelTransport(sessionId, remoteSearchToken); } catch (XmlRpcException &e) { - gLiveSupport->displayMessageWindow(formatMessage( - "remoteSearchErrorMsg", - e.what() )); + displayRemoteSearchError(e); return; } } @@ -547,9 +545,7 @@ SearchWindow :: remoteSearchOpen(Ptr::Ref criteria) try { remoteSearchToken = storage->remoteSearchOpen(sessionId, criteria); } catch (XmlRpcException &e) { - gLiveSupport->displayMessageWindow(formatMessage( - "remoteSearchErrorMsg", - e.what() )); + displayRemoteSearchError(e); } } @@ -571,9 +567,7 @@ SearchWindow :: remoteSearchClose(void) try { state = storage->checkTransport(remoteSearchToken, errorMessage); } catch (XmlRpcException &e) { - gLiveSupport->displayMessageWindow(formatMessage( - "remoteSearchErrorMsg", - e.what() )); + displayRemoteSearchError(e); return; } @@ -583,9 +577,7 @@ SearchWindow :: remoteSearchClose(void) try { storage->remoteSearchClose(remoteSearchToken); } catch (XmlRpcException &e) { - gLiveSupport->displayMessageWindow(formatMessage( - "remoteSearchErrorMsg", - e.what() )); + displayRemoteSearchError(e); return; } remoteSearchToken.reset(); @@ -593,9 +585,7 @@ SearchWindow :: remoteSearchClose(void) try { results = gLiveSupport->getSearchResults(); } catch (XmlRpcException &e) { - gLiveSupport->displayMessageWindow(formatMessage( - "remoteSearchErrorMsg", - e.what() )); + displayRemoteSearchError(e); return; } @@ -603,11 +593,11 @@ SearchWindow :: remoteSearchClose(void) } else if (state == AsyncState::closedState) { remoteSearchToken.reset(); - displayMessage("remoteSearchErrorMsg", remoteSearchResults); + displayMessage("shortErrorMsg", remoteSearchResults); } else if (state == AsyncState::failedState) { - remoteSearchToken.reset(); - displayMessage(*errorMessage, remoteSearchResults); + remoteSearchToken.reset(); + displayMessage(*errorMessage, remoteSearchResults); } } } @@ -630,6 +620,42 @@ SearchWindow :: displayMessage(const Glib::ustring & messageKey, } +/*------------------------------------------------------------------------------ + * Display an error message which occurred during a search. + *----------------------------------------------------------------------------*/ +void +SearchWindow :: displayError(const XmlRpcException & error, + Glib::RefPtr treeModel) + throw () +{ + gLiveSupport->displayMessageWindow(formatMessage("longErrorMsg", + error.what() )); + displayMessage("shortErrorMsg", treeModel); +} + + +/*------------------------------------------------------------------------------ + * Display an error message which occurred during a local search. + *----------------------------------------------------------------------------*/ +inline void +SearchWindow :: displayLocalSearchError(const XmlRpcException & error) + throw () +{ + displayError(error, localSearchResults); +} + + +/*------------------------------------------------------------------------------ + * Display an error message which occurred during a remote search. + *----------------------------------------------------------------------------*/ +inline void +SearchWindow :: displayRemoteSearchError(const XmlRpcException & error) + throw () +{ + displayError(error, remoteSearchResults); +} + + /*------------------------------------------------------------------------------ * Event handler for an entry being clicked in the list *----------------------------------------------------------------------------*/ diff --git a/livesupport/src/products/gLiveSupport/src/SearchWindow.h b/livesupport/src/products/gLiveSupport/src/SearchWindow.h index 13f94ae6b..6266190a5 100644 --- a/livesupport/src/products/gLiveSupport/src/SearchWindow.h +++ b/livesupport/src/products/gLiveSupport/src/SearchWindow.h @@ -418,6 +418,36 @@ class SearchWindow : public GuiWindow Glib::RefPtr treeModel) throw (); + /** + * Display an error message which occurred during a search. + * + * @param error the error which occurred. + * @param treeModel the tree model to display the message in. + */ + void + displayError(const XmlRpcException & error, + Glib::RefPtr treeModel) + throw (); + + /** + * Display an error message which occurred during a local search. + * + * @param error the error which occurred. + */ + void + displayLocalSearchError(const XmlRpcException & error) + throw (); + + /** + * Display an error message which occurred during a remote search. + * + * @param error the error which occurred. + */ + void + displayRemoteSearchError(const XmlRpcException & error) + throw (); + + public: /** diff --git a/livesupport/src/products/gLiveSupport/var/root.txt b/livesupport/src/products/gLiveSupport/var/root.txt index 9524496b8..0ecad0dd1 100644 --- a/livesupport/src/products/gLiveSupport/var/root.txt +++ b/livesupport/src/products/gLiveSupport/var/root.txt @@ -215,7 +215,8 @@ root:table downloadFromHubMenuItem:string { "Download from the network hub" } pleaseWaitMsg:string { "Please wait..." } - remoteSearchErrorMsg:string { "Search failed: {0}." } + shortErrorMsg:string { "Search failed." } + longErrorMsg:string { "Search failed: {0}." } uploadToHubErrorMsg:string { "Uploading to hub failed: {0}." } downloadFromHubErrorMsg:string { "Downloading from hub failed: {0}." } nothingFoundMsg:string { "No files found." }