Browse Source

fix error message and stack in Firefox

in Firefox stack doesn't include the message
tags/v4.34.0
Tobias Koppers 6 months ago
parent
commit
a1d45671c1
5 changed files with 19 additions and 13 deletions
  1. +2
    -2
      hot/dev-server.js
  2. +12
    -0
      hot/log.js
  3. +2
    -5
      hot/only-dev-server.js
  4. +2
    -5
      hot/poll.js
  5. +1
    -1
      hot/signal.js

+ 2
- 2
hot/dev-server.js View File

@@ -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));
}
});
};

+ 12
- 0
hot/log.js View File

@@ -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;
}
};

+ 2
- 5
hot/only-dev-server.js View File

@@ -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));
}
});
};

+ 2
- 5
hot/poll.js View File

@@ -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));
}
});
}

+ 1
- 1
hot/signal.js View File

@@ -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));

Loading…
Cancel
Save