improved error reporting in the search window;

this fixes #1763
This commit is contained in:
fgerlits 2006-08-22 13:06:36 +00:00
parent bb48dc2e47
commit 67758aad31
3 changed files with 77 additions and 20 deletions

View File

@ -453,7 +453,7 @@ SearchWindow :: localSearch(Ptr<SearchCriteria>::Ref criteria)
try { try {
searchResults = gLiveSupport->search(criteria); searchResults = gLiveSupport->search(criteria);
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
std::cerr << e.what() << std::endl; displayLocalSearchError(e);
return; return;
} }
@ -537,9 +537,7 @@ SearchWindow :: remoteSearchOpen(Ptr<SearchCriteria>::Ref criteria)
try { try {
storage->cancelTransport(sessionId, remoteSearchToken); storage->cancelTransport(sessionId, remoteSearchToken);
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
gLiveSupport->displayMessageWindow(formatMessage( displayRemoteSearchError(e);
"remoteSearchErrorMsg",
e.what() ));
return; return;
} }
} }
@ -547,9 +545,7 @@ SearchWindow :: remoteSearchOpen(Ptr<SearchCriteria>::Ref criteria)
try { try {
remoteSearchToken = storage->remoteSearchOpen(sessionId, criteria); remoteSearchToken = storage->remoteSearchOpen(sessionId, criteria);
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
gLiveSupport->displayMessageWindow(formatMessage( displayRemoteSearchError(e);
"remoteSearchErrorMsg",
e.what() ));
} }
} }
@ -571,9 +567,7 @@ SearchWindow :: remoteSearchClose(void)
try { try {
state = storage->checkTransport(remoteSearchToken, errorMessage); state = storage->checkTransport(remoteSearchToken, errorMessage);
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
gLiveSupport->displayMessageWindow(formatMessage( displayRemoteSearchError(e);
"remoteSearchErrorMsg",
e.what() ));
return; return;
} }
@ -583,9 +577,7 @@ SearchWindow :: remoteSearchClose(void)
try { try {
storage->remoteSearchClose(remoteSearchToken); storage->remoteSearchClose(remoteSearchToken);
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
gLiveSupport->displayMessageWindow(formatMessage( displayRemoteSearchError(e);
"remoteSearchErrorMsg",
e.what() ));
return; return;
} }
remoteSearchToken.reset(); remoteSearchToken.reset();
@ -593,9 +585,7 @@ SearchWindow :: remoteSearchClose(void)
try { try {
results = gLiveSupport->getSearchResults(); results = gLiveSupport->getSearchResults();
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
gLiveSupport->displayMessageWindow(formatMessage( displayRemoteSearchError(e);
"remoteSearchErrorMsg",
e.what() ));
return; return;
} }
@ -603,11 +593,11 @@ SearchWindow :: remoteSearchClose(void)
} else if (state == AsyncState::closedState) { } else if (state == AsyncState::closedState) {
remoteSearchToken.reset(); remoteSearchToken.reset();
displayMessage("remoteSearchErrorMsg", remoteSearchResults); displayMessage("shortErrorMsg", remoteSearchResults);
} else if (state == AsyncState::failedState) { } else if (state == AsyncState::failedState) {
remoteSearchToken.reset(); remoteSearchToken.reset();
displayMessage(*errorMessage, remoteSearchResults); 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<Gtk::ListStore> 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 * Event handler for an entry being clicked in the list
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/

View File

@ -418,6 +418,36 @@ class SearchWindow : public GuiWindow
Glib::RefPtr<Gtk::ListStore> treeModel) Glib::RefPtr<Gtk::ListStore> treeModel)
throw (); 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<Gtk::ListStore> 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: public:
/** /**

View File

@ -215,7 +215,8 @@ root:table
downloadFromHubMenuItem:string { "Download from the network hub" } downloadFromHubMenuItem:string { "Download from the network hub" }
pleaseWaitMsg:string { "Please wait..." } 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}." } uploadToHubErrorMsg:string { "Uploading to hub failed: {0}." }
downloadFromHubErrorMsg:string { "Downloading from hub failed: {0}." } downloadFromHubErrorMsg:string { "Downloading from hub failed: {0}." }
nothingFoundMsg:string { "No files found." } nothingFoundMsg:string { "No files found." }