mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-04-27 01:00:26 -04:00
refactor: better error logging (#48903)
* refactor: log full error, not .message and .stack * refactor: improve missing comments error message
This commit is contained in:
committed by
GitHub
parent
4054cf8d06
commit
3c93f73b2d
@@ -70,29 +70,25 @@ const commentExtractors = {
|
||||
|
||||
const { flatten, isEmpty, cloneDeep, isEqual } = lodash;
|
||||
|
||||
// rethrow unhandled rejections to make sure the tests exit with -1
|
||||
// rethrow unhandled rejections to make sure the tests exit with non-zero code
|
||||
process.on('unhandledRejection', err => handleRejection(err));
|
||||
// If an uncaught exception gets here, then mocha is in an unexpected state. All
|
||||
// we can do is log the exception and exit with a non-zero code.
|
||||
process.on('uncaughtException', err => {
|
||||
console.error('Uncaught exception:', err.message);
|
||||
console.error(err.stack);
|
||||
// eslint-disable-next-line no-process-exit
|
||||
console.error('Uncaught exception:');
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
// some errors *may* not be reported, since cleanup is triggered by the first
|
||||
// error and that starts shutting down the browser and the server.
|
||||
const handleRejection = err => {
|
||||
// setting the error code because node does not (yet) exit with a non-zero
|
||||
// code on unhandled exceptions.
|
||||
process.exitCode = 1;
|
||||
cleanup();
|
||||
if (process.env.FULL_OUTPUT === 'true') {
|
||||
// some errors *may* not be reported, since cleanup is triggered by the
|
||||
// first error and that starts shutting down the browser and the server.
|
||||
console.error(err);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
console.error(err);
|
||||
if (process.env.FULL_OUTPUT !== 'true') process.exit();
|
||||
};
|
||||
|
||||
const dom = new jsdom.JSDOM('');
|
||||
|
||||
@@ -100,7 +100,11 @@ function translateGeneric(
|
||||
updateCounts(commentCounts, dict[comment][lang]);
|
||||
text = text.replace(match, `${before}${dict[comment][lang]}${after}`);
|
||||
} else if (comment.trim()) {
|
||||
throw `${comment} does not appear in the comment dictionary`;
|
||||
throw `The comment
|
||||
${comment}
|
||||
does not appear in the comment dictionary.
|
||||
When updating or adding a comment it must have the same text in the English challenges and the comment dictionary.
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user