MCPcopy Index your code
hub / github.com/nodejs/node / constructor

Method constructor

lib/internal/errors.js:810–839  ·  view source on GitHub ↗

* @param {number|string} code - A libuv error number or a c-ares error code * @param {string} syscall * @param {string} [hostname]

(code, syscall, hostname)

Source from the content-addressed store, hash-verified

808 * @param {string} [hostname]
809 */
810 constructor(code, syscall, hostname) {
811 let errno;
812 // If `code` is of type number, it is a libuv error number, else it is a
813 // c-ares/permission model error code.
814 // TODO(joyeecheung): translate c-ares error codes into numeric ones and
815 // make them available in a property that's not error.errno (since they
816 // can be in conflict with libuv error codes). Also make sure
817 // util.getSystemErrorName() can understand them when an being informed that
818 // the number is a c-ares error code.
819 if (typeof code === 'number') {
820 errno = code;
821 // ENOTFOUND is not a proper POSIX error, but this error has been in place
822 // long enough that it's not practical to remove it.
823 if (code === lazyUv().UV_EAI_NODATA || code === lazyUv().UV_EAI_NONAME) {
824 code = 'ENOTFOUND'; // Fabricated error name.
825 } else {
826 code = lazyInternalUtil().getSystemErrorName(code);
827 }
828 } else if (isPermissionModelError(code)) {
829 // Expects a ERR_ACCESS_DENIED object
830 code = code.code;
831 }
832 super(`${syscall} ${code}${hostname ? ` ${hostname}` : ''}`);
833 this.errno = errno;
834 this.code = code;
835 this.syscall = syscall;
836 if (hostname) {
837 this.hostname = hostname;
838 }
839 }
840
841 get ['constructor']() {
842 return Error;

Callers

nothing calls this directly

Calls 3

lazyInternalUtilFunction · 0.85
isPermissionModelErrorFunction · 0.85
lazyUvFunction · 0.70

Tested by

no test coverage detected