mirror of
https://github.com/nodejs/node.git
synced 2024-11-30 07:27:22 +01:00
b9f1e57201
Instead of using the public AssertionError, use a simplified error that describes potential causes of these assertions and suggests the user to open an issue. PR-URL: https://github.com/nodejs/node/pull/26635 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
25 lines
473 B
JavaScript
25 lines
473 B
JavaScript
'use strict';
|
|
|
|
let error;
|
|
function lazyError() {
|
|
if (!error) {
|
|
error = require('internal/errors').codes.ERR_INTERNAL_ASSERTION;
|
|
}
|
|
return error;
|
|
}
|
|
function assert(value, message) {
|
|
if (!value) {
|
|
const ERR_INTERNAL_ASSERTION = lazyError();
|
|
throw new ERR_INTERNAL_ASSERTION(message);
|
|
}
|
|
}
|
|
|
|
function fail(message) {
|
|
const ERR_INTERNAL_ASSERTION = lazyError();
|
|
throw new ERR_INTERNAL_ASSERTION(message);
|
|
}
|
|
|
|
assert.fail = fail;
|
|
|
|
module.exports = assert;
|