Bug 1094485 - Properly handle exceptions in readerWorker.js. r=bnicholson, a=metered

This commit is contained in:
Margaret Leibovic 2014-11-06 14:07:55 -08:00
Родитель 0c68fcbccc
Коммит 9feebaa60a
3 изменённых файлов: 13 добавлений и 6 удалений

Просмотреть файл

@ -145,6 +145,7 @@ let Reader = {
* @param tabId (optional) The id of the tab where we can look for a saved article.
* @return {Promise}
* @resolves JS object representing the article, or null if no article is found.
* @rejects Never.
*/
getArticle: Task.async(function* (url, tabId) {
// First, look for an article object stored on the tab.
@ -167,7 +168,10 @@ let Reader = {
// Article hasn't been found in the cache, we need to
// download the page and parse the article out of it.
return yield this._downloadAndParseDocument(url);
return yield this._downloadAndParseDocument(url).catch(e => {
Cu.reportError("Error downloading and parsing article: " + e);
return null;
});
}),
/**
@ -287,6 +291,10 @@ let Reader = {
resolve(article);
};
worker.onerror = function (evt) {
reject(evt.message);
};
try {
worker.postMessage({
uri: {
@ -354,7 +362,6 @@ let Reader = {
this.log("Finished loading page: " + doc);
try {
this.log("Parsing response with Readability");
let uri = Services.io.newURI(url, null, null);
let article = yield this._readerParse(uri, doc);
this.log("Document parsed successfully");

Просмотреть файл

@ -512,10 +512,10 @@ AboutReader.prototype = {
_loadArticle: Task.async(function* (url, tabId) {
this._showProgressDelayed();
try {
let article = yield gChromeWin.Reader.getArticle(url, tabId);
let article = yield gChromeWin.Reader.getArticle(url, tabId);
if (article) {
this._showContent(article);
} catch (e) {
} else {
this._win.location.href = url;
}
}),

Просмотреть файл

@ -4250,7 +4250,7 @@ Tab.prototype = {
if(!this.readerEnabled)
this.readerEnabled = true;
}, e => Cu.reportError(e));
}, e => Cu.reportError("Error parsing document from tab: " + e));
}
}
},