Skip to content

Commit

Permalink
Catch XHR errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkluijk committed Aug 17, 2018
1 parent 6e8659d commit b024dfe
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions source-map-support.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,16 @@ retrieveFileHandlers.push(function(path) {

var contents = null;
if (!fs) {
// Use SJAX if we are in the browser
var xhr = new XMLHttpRequest();
xhr.open('GET', path, false);
xhr.send(null);
var contents = null
if (xhr.readyState === 4 && xhr.status === 200) {
contents = xhr.responseText
try {
// Use SJAX if we are in the browser
var xhr = new XMLHttpRequest();
xhr.open('GET', path, /** async */ false);
xhr.send(null);
if (xhr.readyState === 4 && xhr.status === 200) {
contents = xhr.responseText;
}
} catch (er) {
contents = '';
}
} else if (fs.existsSync(path)) {
// Otherwise, use the filesystem
Expand Down

0 comments on commit b024dfe

Please sign in to comment.