node/test/internet
Joyee Cheung 1432065e9d
lib: correct error.errno to always be numeric
Historically `error.errno` of system errors thrown by Node.js
can sometimes be the same as `err.code`, which are string
representations of the error numbers. This is useless and incorrect,
and results in an information loss for users since then they
will have to resort to something like
`process.binding('uv'[`UV_${errno}`])` to get to the numeric
error codes.

This patch corrects this behavior by always setting `error.errno`
to be negative numbers. For fabricated errors like `ENOTFOUND`,
`error.errno` is now undefined since there is no numeric equivalent
for them anyway. For c-ares errors, `error.errno` is now undefined
because the numeric representations (negated) can be in conflict
with libuv error codes - this is fine since numeric codes was
not available for c-ares errors anyway.

Users can use the public API `util.getSystemErrorName(errno)`
to retrieve string codes for these numbers.

PR-URL: https://github.com/nodejs/node/pull/28140
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-06-17 10:18:09 +08:00
..
test-dgram-broadcast-multi-process.js test: refactor test-dgram-broadcast-multi-process 2019-03-23 19:58:04 -07:00
test-dgram-connect.js test: use common.PORT instead of an extraneous variable 2019-05-13 14:26:40 -07:00
test-dgram-membership.js test: remove assert.doesNotThrow() 2018-02-16 16:53:47 +01:00
test-dgram-multicast-multi-process.js test: remove unused catch bindings 2018-11-06 10:59:18 -05:00
test-dgram-multicast-set-interface-lo.js test: rename some allegories 2018-08-14 17:54:40 +03:00
test-dgram-send-cb-quelches-error.js test: remove common.fail() 2017-04-12 14:25:33 -07:00
test-dns-any.js test: make crashOnUnhandleRejection opt-out 2018-07-19 08:47:28 +02:00
test-dns-cares-domains.js test: use internet.addresses in internet tests 2017-11-08 18:54:20 +08:00
test-dns-idna2008.js test: fix test-dns-idna2008.js 2019-04-14 22:40:06 -07:00
test-dns-ipv4.js test: make crashOnUnhandleRejection opt-out 2018-07-19 08:47:28 +02:00
test-dns-ipv6.js test: make crashOnUnhandleRejection opt-out 2018-07-19 08:47:28 +02:00
test-dns-lookup.js test: add dns.onlookupall() to increase coverage 2018-09-27 05:40:12 +02:00
test-dns-promises-resolve.js benchmark,doc,lib,test: capitalize comments 2019-02-28 18:31:10 +01:00
test-dns-regress-6244.js test: refactor test-dns-regress-6244.js 2017-05-18 23:02:31 +02:00
test-dns-setserver-in-callback-of-resolve4.js dns: fix crash while setting server during query 2017-12-06 04:22:31 +01:00
test-dns-txt-sigsegv.js test: make crashOnUnhandleRejection opt-out 2018-07-19 08:47:28 +02:00
test-dns.js lib: correct error.errno to always be numeric 2019-06-17 10:18:09 +08:00
test-doctool-versions.js doc,tools: get altDocs versions from CHANGELOG.md 2019-06-01 10:17:30 +02:00
test-http-dns-fail.js meta: restore original copyright header 2017-03-10 11:23:48 -08:00
test-http-https-default-ports.js test: refactor http-https-default-ports 2018-03-09 15:16:31 +00:00
test-inspector-help-page.js test: verify inspector help url works 2018-04-10 15:42:32 -04:00
test-net-connect-timeout.js meta: restore original copyright header 2017-03-10 11:23:48 -08:00
test-net-connect-unref.js test: remove setTimeout in test-net-connect-unref 2018-07-26 16:43:21 -07:00
test-tls-add-ca-cert.js test: continue normalizing fixtures use 2017-08-27 21:14:34 -03:00
test-tls-connnect-melissadata.js test: simplify test skipping 2017-07-04 12:41:49 +03:00
test-tls-reuse-host-from-socket.js test: use shorthand properties 2018-01-17 14:33:20 +01:00
test-trace-events-dns.js test: don't inspect values if not necessary 2018-09-18 13:12:34 +02:00
test-uv-threadpool-schedule.js test: tune test-uv-threadpool-schedule 2019-01-07 19:08:05 -08:00
testcfg.py test: refactor to use common testcfg 2014-01-20 09:00:13 -08:00