Skip to content

Commit f2e298f

Browse files
committed
Refactor try/catch
1 parent b024dfe commit f2e298f

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

source-map-support.js

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

81-
var contents = null;
82-
if (!fs) {
83-
try {
81+
var contents = '';
82+
try {
83+
if (!fs) {
8484
// Use SJAX if we are in the browser
8585
var xhr = new XMLHttpRequest();
8686
xhr.open('GET', path, /** async */ false);
8787
xhr.send(null);
8888
if (xhr.readyState === 4 && xhr.status === 200) {
8989
contents = xhr.responseText;
9090
}
91-
} catch (er) {
92-
contents = '';
93-
}
94-
} else if (fs.existsSync(path)) {
95-
// Otherwise, use the filesystem
96-
try {
91+
} else if (fs.existsSync(path)) {
92+
// Otherwise, use the filesystem
9793
contents = fs.readFileSync(path, 'utf8');
98-
} catch (er) {
99-
contents = '';
10094
}
95+
} catch (er) {
96+
/* ignore any errors */
10197
}
10298

10399
return fileContentsCache[path] = contents;

0 commit comments

Comments
 (0)