mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
lib, test: add duplicate symbol checking in E()
Add duplicate symbol checking in E() to avoid potential confusing result. Increase coverage of internal/errors. PR-URL: https://github.com/nodejs/node/pull/11829 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
This commit is contained in:
1 parent
5bd1642dd1
commit
b5eccc4c7e
2 files changed
+14
No files matched your search
@@ -60,6 +60,8 @@ function message(key, args) {
|
||||
// Utility function for registering the error codes. Only used here. Exported
|
||||
// *only* to allow for testing.
|
||||
function E(sym, val) {
|
||||
const assert = lazyAssert();
|
||||
assert(messages.has(sym) === false, `Error symbol: ${sym} was already used.`);
|
||||
messages.set(sym, typeof val === 'function' ? val : String(val));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user