internal/util: use internal/errors.js
PR-URL: https://github.com/nodejs/node/pull/11301 Refs: https://github.com/nodejs/node/issues/11273 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Franziska Hinkelmann <fhinkel@vt.edu> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
parent
c7323af131
commit
de4a749788
@ -748,6 +748,12 @@ Used when data cannot be sent on a socket.
|
|||||||
|
|
||||||
Used when a call is made and the UDP subsystem is not running.
|
Used when a call is made and the UDP subsystem is not running.
|
||||||
|
|
||||||
|
<a id="ERR_NO_CRYPTO"></a>
|
||||||
|
### ERR_NO_CRYPTO
|
||||||
|
|
||||||
|
Used when an attempt is made to use crypto features while Node.js is not
|
||||||
|
compiled with OpenSSL crypto support.
|
||||||
|
|
||||||
<a id="ERR_STDERR_CLOSE"></a>
|
<a id="ERR_STDERR_CLOSE"></a>
|
||||||
### ERR_STDERR_CLOSE
|
### ERR_STDERR_CLOSE
|
||||||
|
|
||||||
|
@ -155,6 +155,7 @@ E('ERR_IPC_SYNC_FORK', 'IPC cannot be used with synchronous forks');
|
|||||||
E('ERR_MISSING_ARGS', missingArgs);
|
E('ERR_MISSING_ARGS', missingArgs);
|
||||||
E('ERR_PARSE_HISTORY_DATA',
|
E('ERR_PARSE_HISTORY_DATA',
|
||||||
(oldHistoryPath) => `Could not parse history data in ${oldHistoryPath}`);
|
(oldHistoryPath) => `Could not parse history data in ${oldHistoryPath}`);
|
||||||
|
E('ERR_NO_CRYPTO', 'Node.js is not compiled with OpenSSL crypto support');
|
||||||
E('ERR_STDERR_CLOSE', 'process.stderr cannot be closed');
|
E('ERR_STDERR_CLOSE', 'process.stderr cannot be closed');
|
||||||
E('ERR_STDOUT_CLOSE', 'process.stdout cannot be closed');
|
E('ERR_STDOUT_CLOSE', 'process.stdout cannot be closed');
|
||||||
E('ERR_TRANSFORM_ALREADY_TRANSFORMING',
|
E('ERR_TRANSFORM_ALREADY_TRANSFORMING',
|
||||||
|
@ -34,7 +34,7 @@ function deprecate(fn, msg, code) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (code !== undefined && typeof code !== 'string')
|
if (code !== undefined && typeof code !== 'string')
|
||||||
throw new TypeError('`code` argument must be a string');
|
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'code', 'string');
|
||||||
|
|
||||||
var warned = false;
|
var warned = false;
|
||||||
function deprecated(...args) {
|
function deprecated(...args) {
|
||||||
@ -79,7 +79,7 @@ function decorateErrorStack(err) {
|
|||||||
|
|
||||||
function assertCrypto() {
|
function assertCrypto() {
|
||||||
if (noCrypto)
|
if (noCrypto)
|
||||||
throw new Error('Node.js is not compiled with openssl crypto support');
|
throw new errors.Error('ERR_NO_CRYPTO');
|
||||||
}
|
}
|
||||||
|
|
||||||
// The loop should only run at most twice, retrying with lowercased enc
|
// The loop should only run at most twice, retrying with lowercased enc
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
// Flags: --expose-internals
|
// Flags: --expose-internals
|
||||||
'use strict';
|
'use strict';
|
||||||
require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const util = require('internal/util');
|
const util = require('internal/util');
|
||||||
|
|
||||||
|
const expectedError = common.expectsError({
|
||||||
|
code: 'ERR_NO_CRYPTO',
|
||||||
|
type: Error
|
||||||
|
});
|
||||||
|
|
||||||
if (!process.versions.openssl) {
|
if (!process.versions.openssl) {
|
||||||
assert.throws(
|
assert.throws(() => util.assertCrypto(), expectedError);
|
||||||
() => util.assertCrypto(),
|
|
||||||
/^Error: Node\.js is not compiled with openssl crypto support$/
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
assert.doesNotThrow(() => util.assertCrypto());
|
assert.doesNotThrow(() => util.assertCrypto());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user