Skip to content

Commit

Permalink
fix error message and stack in Firefox
Browse files Browse the repository at this point in the history
in Firefox stack doesn't include the message
  • Loading branch information
sokra committed Jun 12, 2019
1 parent acf2c2d commit a1d4567
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
4 changes: 2 additions & 2 deletions hot/dev-server.js
Expand Up @@ -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));
}
});
};
Expand Down
12 changes: 12 additions & 0 deletions hot/log.js
Expand Up @@ -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;
}
};
7 changes: 2 additions & 5 deletions hot/only-dev-server.js
Expand Up @@ -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));
}
});
};
Expand Down
7 changes: 2 additions & 5 deletions hot/poll.js
Expand Up @@ -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));
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion hot/signal.js
Expand Up @@ -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));
Expand Down

0 comments on commit a1d4567

Please sign in to comment.