Permalink
Browse files

internal/util: use internal/errors.js

PR-URL: #11301
Refs: #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>
  • Loading branch information...
seppevs authored and tniessen committed Feb 10, 2017
1 parent c7323af commit de4a749788aa88b6f23f50eccb7a6752f6bb59b7
Showing with 16 additions and 7 deletions.
  1. +6 −0 doc/api/errors.md
  2. +1 −0 lib/internal/errors.js
  3. +2 −2 lib/internal/util.js
  4. +7 −5 test/parallel/test-internal-util-assertCrypto.js
View
@@ -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.
<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>
### ERR_STDERR_CLOSE
View
@@ -155,6 +155,7 @@ E('ERR_IPC_SYNC_FORK', 'IPC cannot be used with synchronous forks');
E('ERR_MISSING_ARGS', missingArgs);
E('ERR_PARSE_HISTORY_DATA',
(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_STDOUT_CLOSE', 'process.stdout cannot be closed');
E('ERR_TRANSFORM_ALREADY_TRANSFORMING',
View
@@ -34,7 +34,7 @@ function deprecate(fn, msg, code) {
}
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;
function deprecated(...args) {
@@ -79,7 +79,7 @@ function decorateErrorStack(err) {
function assertCrypto() {
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
@@ -1,14 +1,16 @@
// Flags: --expose-internals
'use strict';
require('../common');
const common = require('../common');
const assert = require('assert');
const util = require('internal/util');
const expectedError = common.expectsError({
code: 'ERR_NO_CRYPTO',
type: Error
});
if (!process.versions.openssl) {
assert.throws(
() => util.assertCrypto(),
/^Error: Node\.js is not compiled with openssl crypto support$/
);
assert.throws(() => util.assertCrypto(), expectedError);
} else {
assert.doesNotThrow(() => util.assertCrypto());
}

0 comments on commit de4a749

Please sign in to comment.