Add error handling to newsfeed

This commit is contained in:
Ben Brosnahan 2017-01-02 21:31:21 +00:00
parent 6febcf3b94
commit a7619771a6

View File

@ -85,7 +85,12 @@ var Fetcher = function(url, reloadInterval, encoding) {
nodeVersion = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
headers = {"User-Agent": "Mozilla/5.0 (Node.js "+ nodeVersion + ") MagicMirror/" + global.version + " (https://github.com/MichMich/MagicMirror/)"}
request({uri: url, encoding: null, headers: headers}).pipe(iconv.decodeStream(encoding)).pipe(parser);
request({uri: url, encoding: null, headers: headers})
.on("error", function(error) {
fetchFailedCallback(self, error);
scheduleTimer();
})
.pipe(iconv.decodeStream(encoding)).pipe(parser);
};