Prevent the development viewer, started with gulp server, from breaking completely in Private Browsing mode

Since attempting to access `IndexedDB` in Private Browsing mode in Firefox will throw an error, see https://bugzilla.mozilla.org/show_bug.cgi?id=781982, the development viewer fails to load.
This commit is contained in:
Jonas Jenwald 2018-07-02 14:01:45 +02:00
parent 42922c9ae5
commit 8f0cc07116

View File

@ -33,6 +33,7 @@ function getDb() {
resolve(db);
};
request.onerror = function () {
console.warn('getDb: ' + request.error);
reject(request.error);
};
});
@ -95,7 +96,7 @@ function sha256(str) {
}
exports.translate = function (load, opt) {
var savedHashCode;
var savedHashCode, babelTranslateError;
return sha256(load.source).then(function (hashCode) {
savedHashCode = hashCode;
return loadCache(load.address, hashCode);
@ -109,6 +110,13 @@ exports.translate = function (load, opt) {
translated, load.metadata.format).then(function () {
return translated;
});
}, function(reason) {
throw (babelTranslateError = reason);
});
}.bind(this)).catch(function(reason) {
if (babelTranslateError) {
throw babelTranslateError;
}
return babel.translate.call(this, load, opt);
}.bind(this));
};