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 {
searchResults = gLiveSupport->search(criteria);
} catch (XmlRpcException &e) {
std::cerr << e.what() << std::endl;
displayLocalSearchError(e);
return;
}
@ -537,9 +537,7 @@ SearchWindow :: remoteSearchOpen(Ptr<SearchCriteria>::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<SearchCriteria>::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<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
*----------------------------------------------------------------------------*/

View File

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

View File

@ -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." }