diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-03-18 15:41:19 +0100 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-03-21 22:52:08 +0100 |
commit | 39f4158bc38ff2925b86563082c8d26ab3d20b17 (patch) | |
tree | 9e1a669fd41379bcd9b85bdf0e17fde5033a2c77 /lib/tls.js | |
parent | df0870dddf15ab5396ab9842fdbe4c06a8186cda (diff) | |
download | android-node-v8-39f4158bc38ff2925b86563082c8d26ab3d20b17.tar.gz android-node-v8-39f4158bc38ff2925b86563082c8d26ab3d20b17.tar.bz2 android-node-v8-39f4158bc38ff2925b86563082c8d26ab3d20b17.zip |
lib: move extra properties into error creation
This encapsulates the Node.js errors more by adding extra properties
to an error inside of the function to create the error message instead
of adding the properties at the call site. That simplifies the usage
of our errors and makes sure the expected properties are always set.
PR-URL: https://github.com/nodejs/node/pull/26752
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/tls.js')
-rw-r--r-- | lib/tls.js | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/lib/tls.js b/lib/tls.js index 9d2b9add66..024a81289a 100644 --- a/lib/tls.js +++ b/lib/tls.js @@ -258,11 +258,7 @@ exports.checkServerIdentity = function checkServerIdentity(hostname, cert) { } if (!valid) { - const err = new ERR_TLS_CERT_ALTNAME_INVALID(reason); - err.reason = reason; - err.host = hostname; - err.cert = cert; - return err; + return new ERR_TLS_CERT_ALTNAME_INVALID(reason, hostname, cert); } }; |