Skip to content

Commit d665b19

Browse files
authored
Merge pull request #222 from dirkluijk/xhr-error-catch
Catch XHR errors
2 parents 6e8659d + f2e298f commit d665b19

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

source-map-support.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,23 +78,22 @@ retrieveFileHandlers.push(function(path) {
7878
return fileContentsCache[path];
7979
}
8080

81-
var contents = null;
82-
if (!fs) {
83-
// Use SJAX if we are in the browser
84-
var xhr = new XMLHttpRequest();
85-
xhr.open('GET', path, false);
86-
xhr.send(null);
87-
var contents = null
88-
if (xhr.readyState === 4 && xhr.status === 200) {
89-
contents = xhr.responseText
90-
}
91-
} else if (fs.existsSync(path)) {
92-
// Otherwise, use the filesystem
93-
try {
81+
var contents = '';
82+
try {
83+
if (!fs) {
84+
// Use SJAX if we are in the browser
85+
var xhr = new XMLHttpRequest();
86+
xhr.open('GET', path, /** async */ false);
87+
xhr.send(null);
88+
if (xhr.readyState === 4 && xhr.status === 200) {
89+
contents = xhr.responseText;
90+
}
91+
} else if (fs.existsSync(path)) {
92+
// Otherwise, use the filesystem
9493
contents = fs.readFileSync(path, 'utf8');
95-
} catch (er) {
96-
contents = '';
9794
}
95+
} catch (er) {
96+
/* ignore any errors */
9897
}
9998

10099
return fileContentsCache[path] = contents;

0 commit comments

Comments
 (0)