Skip to content

Commit 73ba422

Browse files
committed
Throw error on bad URL passed into parser
1 parent ceab01e commit 73ba422

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

dist/rss-parser.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ Parser.parseURL = function(url, callback) {
5353

5454
try{ xhr = new XMLHttpRequest(); }catch(e){
5555
try{ xhr = new ActiveXObject('Msxml2.XMLHTTP'); }catch (error){
56-
if (console) console.log('RSSParser: XMLHttpRequest not supported');
57-
return null;
56+
callback(new Error('RSSParser: XMLHttpRequest not supported'));
5857
}
5958
}
6059
requestTimeout = setTimeout(function() {
@@ -72,8 +71,12 @@ Parser.parseURL = function(url, callback) {
7271
}
7372
};
7473

75-
xhr.open('GET', url, true);
76-
xhr.send();
74+
try {
75+
xhr.open('GET', url, true);
76+
xhr.send();
77+
} catch (err) {
78+
callback(new Error(err));
79+
}
7780
}
7881

7982
Parser.parseFile = function(file, callback) {

0 commit comments

Comments
 (0)