From 1d2fd8b65bacaf4401450edc8ed529106cbcfc67 Mon Sep 17 00:00:00 2001 From: Michaƫl Zasso Date: Sun, 4 Mar 2018 22:16:24 +0100 Subject: lib: port remaining errors to new system PR-URL: https://github.com/nodejs/node/pull/19137 Reviewed-By: Anatoli Papirovski Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell Reviewed-By: Joyee Cheung --- lib/_tls_common.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'lib/_tls_common.js') diff --git a/lib/_tls_common.js b/lib/_tls_common.js index fcb6de8166..f63acad8ad 100644 --- a/lib/_tls_common.js +++ b/lib/_tls_common.js @@ -24,7 +24,10 @@ const { parseCertString } = require('internal/tls'); const { isArrayBufferView } = require('internal/util/types'); const tls = require('tls'); -const errors = require('internal/errors'); +const { + ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED, + ERR_INVALID_ARG_TYPE +} = require('internal/errors').codes; const { SSL_OP_CIPHER_SERVER_PREFERENCE } = process.binding('constants').crypto; @@ -56,8 +59,8 @@ function SecureContext(secureProtocol, secureOptions, context) { function validateKeyCert(value, type) { if (typeof value !== 'string' && !isArrayBufferView(value)) - throw new errors.TypeError( - 'ERR_INVALID_ARG_TYPE', type, + throw new ERR_INVALID_ARG_TYPE( + type, ['string', 'Buffer', 'TypedArray', 'DataView'] ); } @@ -212,12 +215,11 @@ exports.createSecureContext = function createSecureContext(options, context) { if (c.context.setClientCertEngine) c.context.setClientCertEngine(options.clientCertEngine); else - throw new errors.Error('ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED'); + throw new ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED(); } else if (options.clientCertEngine != null) { - throw new errors.TypeError('ERR_INVALID_ARG_TYPE', - 'options.clientCertEngine', - ['string', 'null', 'undefined'], - options.clientCertEngine); + throw new ERR_INVALID_ARG_TYPE('options.clientCertEngine', + ['string', 'null', 'undefined'], + options.clientCertEngine); } return c; -- cgit v1.2.3