Add basic error handling to search system.

If a search provider misbehaves, the search system fails to return any
results from any providers. Work around this.

https://bugzilla.gnome.org/show_bug.cgi?id=627950
This commit is contained in:
Tor-björn Claesson 2010-09-21 11:36:24 +02:00 committed by Florian Müllner
parent 437538644e
commit 4571a0ea0d

View File

@ -258,16 +258,24 @@ SearchSystem.prototype = {
if (isSubSearch) { if (isSubSearch) {
for (let i = 0; i < this._previousResults.length; i++) { for (let i = 0; i < this._previousResults.length; i++) {
let [provider, previousResults] = this._previousResults[i]; let [provider, previousResults] = this._previousResults[i];
let providerResults = provider.getSubsearchResultSet(previousResults, terms); try {
if (providerResults.length > 0) let providerResults = provider.getSubsearchResultSet(previousResults, terms);
results.push([provider, providerResults]); if (providerResults.length > 0)
results.push([provider, providerResults]);
} catch (error) {
global.log ('A ' + error.name + ' has occured in ' + provider.title + ': ' + error.message);
}
} }
} else { } else {
for (let i = 0; i < this._providers.length; i++) { for (let i = 0; i < this._providers.length; i++) {
let provider = this._providers[i]; let provider = this._providers[i];
let providerResults = provider.getInitialResultSet(terms); try {
if (providerResults.length > 0) let providerResults = provider.getInitialResultSet(terms);
results.push([provider, providerResults]); if (providerResults.length > 0)
results.push([provider, providerResults]);
} catch (error) {
global.log ('A ' + error.name + ' has occured in ' + provider.title + ': ' + error.message);
}
} }
} }