Skip to content

Commit b024dfe

Browse files
committed
Catch XHR errors
1 parent 6e8659d commit b024dfe

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

source-map-support.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,16 @@ retrieveFileHandlers.push(function(path) {
8080

8181
var contents = null;
8282
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
83+
try {
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+
} catch (er) {
92+
contents = '';
9093
}
9194
} else if (fs.existsSync(path)) {
9295
// Otherwise, use the filesystem

0 commit comments

Comments
 (0)