Skip to content

Commit 19b843f

Browse files
committed
refactor(tpl): extract log error
1 parent 6fb0dc1 commit 19b843f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/tpl/frontend/index.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@
1414
var noop = function () {
1515
};
1616

17+
var logError;
18+
if (typeof console !== strUndef) {
19+
logError = function (err) {
20+
console.error(err);
21+
}
22+
} else {
23+
logError = noop;
24+
}
25+
1726
var hasClass, addClass, removeClass;
1827
if (document.body.classList) {
1928
hasClass = function (el, className) {
@@ -572,7 +581,7 @@
572581
var relativePath = dirPath + file.name;
573582
files.push({file: file, relativePath: relativePath});
574583
})['catch'](function (err) { // workaround IE8- syntax error for ".catch"(reserved keyword)
575-
typeof console !== strUndef && console.error(err);
584+
logError(err);
576585
});
577586
} else if (handle.kind === handleKindDir) {
578587
return new Promise(function (resolve) {
@@ -652,7 +661,7 @@
652661
increaseCb();
653662
}, function (err) {
654663
increaseCb();
655-
typeof console !== strUndef && console.error(err);
664+
logError(err);
656665
});
657666
} else if (entry.isDirectory) {
658667
var reader = entry.createReader();
@@ -1215,7 +1224,7 @@
12151224
var elItemParent = elItem.parentNode;
12161225
elItemParent && elItemParent.removeChild(elItem);
12171226
} else {
1218-
typeof console != strUndef && console.error('delete failed', status, this.statusText)
1227+
logError('delete failed: ' + status + ' ' + this.statusText);
12191228
}
12201229
}
12211230

0 commit comments

Comments
 (0)