From da3265ad82e3e8ede3246e9c5e086ab6620d0702 Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Wed, 13 Sep 2017 13:29:42 +0200 Subject: [PATCH] errors: backport ERR_INVALID_PROTOCOL to v8.x This error code originally landed in a semver-major commit and is used by the ESM implementation. This backport includes the error message and the documentation for the error. I did attempt to write a test for this, but it did not seem possible to catch an exception during import, I was also unable to execute `node --experimental-modules` properly inside of a child_process. I'll dig more into getting a test together, but we should backport this fix in the mean time. Refs: https://github.com/nodejs/node/pull/14423 Fixes: https://github.com/nodejs/node/issues/15374 PR-URL: https://github.com/nodejs/node/pull/15388 Reviewed-By: Bradley Farias Reviewed-By: James M Snell --- doc/api/errors.md | 5 +++++ lib/internal/errors.js | 2 ++ 2 files changed, 7 insertions(+) diff --git a/doc/api/errors.md b/doc/api/errors.md index 0df38e69f71815..81e7cc6d73492e 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -835,6 +835,11 @@ communication channel to a child process. See [`subprocess.send()`] and Used generically to identify when an invalid or unexpected value has been passed in an options object. + +### ERR_INVALID_PROTOCOL + +Used when an invalid `options.protocol` is passed. + ### ERR_INVALID_SYNC_FORK_INPUT diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 3afbc68d963841..3029f504ba6839 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -196,6 +196,8 @@ E('ERR_INVALID_OPT_VALUE', return `The value "${String(value)}" is invalid for option "${name}"`; }); E('ERR_INVALID_PERFORMANCE_MARK', 'The "%s" performance mark has not been set'); +E('ERR_INVALID_PROTOCOL', (protocol, expectedProtocol) => + `Protocol "${protocol}" not supported. Expected "${expectedProtocol}"`); E('ERR_INVALID_SYNC_FORK_INPUT', (value) => { return 'Asynchronous forks do not support Buffer, Uint8Array or string' +