fix error message and stack in Firefox

in Firefox stack doesn't include the message
This commit is contained in:
Tobias Koppers 2019-06-12 15:28:45 +02:00
vanhempi acf2c2d4b1
commit a1d45671c1
5 muutettua tiedostoa jossa 19 lisäystä ja 13 poistoa

Näytä tiedosto

@ -40,10 +40,10 @@ if (module.hot) {
"warning",
"[HMR] Cannot apply update. Need to do a full reload!"
);
log("warning", "[HMR] " + (err.stack || err.message));
log("warning", "[HMR] " + log.formatError(err));
window.location.reload();
} else {
log("warning", "[HMR] Update failed: " + (err.stack || err.message));
log("warning", "[HMR] Update failed: " + log.formatError(err));
}
});
};

Näytä tiedosto

@ -45,3 +45,15 @@ module.exports.groupEnd = logGroup(groupEnd);
module.exports.setLogLevel = function(level) {
logLevel = level;
};
module.exports.formatError = function(err) {
var message = err.message;
var stack = err.stack;
if (!stack) {
return message;
} else if (stack.indexOf(message) < 0) {
return message + "\n" + stack;
} else {
return stack;
}
};

Näytä tiedosto

@ -72,12 +72,9 @@ if (module.hot) {
"warning",
"[HMR] Cannot check for update. Need to do a full reload!"
);
log("warning", "[HMR] " + (err.stack || err.message));
log("warning", "[HMR] " + log.formatError(err));
} else {
log(
"warning",
"[HMR] Update check failed: " + (err.stack || err.message)
);
log("warning", "[HMR] Update check failed: " + log.formatError(err));
}
});
};

Näytä tiedosto

@ -23,13 +23,10 @@ if (module.hot) {
var status = module.hot.status();
if (["abort", "fail"].indexOf(status) >= 0) {
log("warning", "[HMR] Cannot apply update.");
log("warning", "[HMR] " + (err.stack || err.message));
log("warning", "[HMR] " + log.formatError(err));
log("warning", "[HMR] You need to restart the application!");
} else {
log(
"warning",
"[HMR] Update failed: " + (err.stack || err.message)
);
log("warning", "[HMR] Update failed: " + log.formatError(err));
}
});
}

Näytä tiedosto

@ -37,7 +37,7 @@ if (module.hot) {
var status = module.hot.status();
if (["abort", "fail"].indexOf(status) >= 0) {
log("warning", "[HMR] Cannot apply update.");
log("warning", "[HMR] " + (err.stack || err.message));
log("warning", "[HMR] " + log.formatError(err));
log("warning", "[HMR] You need to restart the application!");
} else {
log("warning", "[HMR] Update failed: " + (err.stack || err.message));