Skip to content

https: use internal/errors.js #11293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ found [here][online].
the connected party did not properly respond after a period of time. Usually
encountered by [`http`][] or [`net`][] -- often a sign that a `socket.end()`
was not properly called.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Micro-nit: stray space can be removed?


<a id="nodejs-error-codes"></a>
## Node.js Error Codes
Expand Down Expand Up @@ -703,6 +703,12 @@ in some cases may accept `func(undefined)` but not `func()`). In most native
Node.js APIs, `func(undefined)` and `func()` are treated identically, and the
[`ERR_INVALID_ARG_TYPE`][] error code may be used instead.

<a id="ERR_HTTP_NO_DOMAIN"></a>
### ERR_HTTP_NO_DOMAIN

An error using the `'ERR_HTTP_NO_DOMAIN'` code is thrown specifically when an attempt
is made to parse an URL without a valid domain name.

<a id="ERR_STDERR_CLOSE"></a>
### ERR_STDERR_CLOSE

Expand Down
3 changes: 2 additions & 1 deletion lib/https.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const util = require('util');
const inherits = util.inherits;
const debug = util.debuglog('https');
const { urlToOptions, searchParamsSymbol } = require('internal/url');
const errors = require('internal/errors');

function Server(opts, requestListener) {
if (!(this instanceof Server)) return new Server(opts, requestListener);
Expand Down Expand Up @@ -219,7 +220,7 @@ exports.request = function request(options, cb) {
if (typeof options === 'string') {
options = url.parse(options);
if (!options.hostname) {
throw new Error('Unable to determine the domain name');
throw new errors.Error('ERR_HTTP_NO_DOMAIN');
}
} else if (options && options[searchParamsSymbol] &&
options[searchParamsSymbol][searchParamsSymbol]) {
Expand Down
1 change: 1 addition & 0 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ E('ERR_IPC_DISCONNECTED', 'IPC channel is already disconnected');
E('ERR_IPC_ONE_PIPE', 'Child process can have only one IPC pipe');
E('ERR_IPC_SYNC_FORK', 'IPC cannot be used with synchronous forks');
E('ERR_MISSING_ARGS', missingArgs);
E('ERR_HTTP_NO_DOMAIN', 'Unable to determine the domain name');
E('ERR_STDERR_CLOSE', 'process.stderr cannot be closed');
E('ERR_STDOUT_CLOSE', 'process.stdout cannot be closed');
E('ERR_UNKNOWN_BUILTIN_MODULE', (id) => `No such built-in module: ${id}`);
Expand Down