How to use the _errnoException function from util

Find comprehensive JavaScript util._errnoException code examples handpicked from public code repositorys.

45
46
47
48
49
50
51
52
53

// `cluster` is only used by `listenInCluster` so for startup performance
// reasons it's lazy loaded.
var cluster = null;

const errnoException = util._errnoException;
const exceptionWithHostPort = util._exceptionWithHostPort;

function noop() {}
fork icon0
star icon3
watch icon1

30
31
32
33
34
35
36
37
38
39

// lazily loaded
var cluster = null;
var dns = null;

var errnoException = util._errnoException;

function lookup(address, family, callback) {
  if (!dns)
    dns = require('dns');
fork icon0
star icon11
watch icon3

175
176
177
178
179
180
181
182
183
184
const oldCols = this.columns;
const oldRows = this.rows;
const winSize = new Array(2);
const err = this._handle.getWindowSize(winSize);
if (err) {
  this.emit('error', _errnoException(err, 'getWindowSize'));
  return;
}
const [newCols, newRows] = winSize;
if (oldCols !== newCols || oldRows !== newRows) {
fork icon0
star icon0
watch icon2

37
38
39
40
41
42
43
44
45
46
    ex.code = 'ENOTFOUND';
    ex.errno = 'ENOTFOUND';
    ex.syscall = syscall;
    return ex;
  }
  return util._errnoException(err, syscall);
}


// c-ares invokes a callback either synchronously or asynchronously,
fork icon0
star icon0
watch icon3

28
29
30
31
32
33
34
35
36
37
  type = conf.type;
  server();
}

function fail(err, syscall) {
  throw util._errnoException(err, syscall);
}

function server() {
  var serverHandle = new TCP();
fork icon0
star icon0
watch icon2

40
41
42
43
44
45
46
47
48
49
  ex = new Error(syscall + ' ' + err);
  ex.code = err;
  ex.errno = err;
  ex.syscall = syscall;
} else {
  ex = util._errnoException(err, syscall);
}
if (hostname) {
  ex.hostname = hostname;
}
fork icon0
star icon0
watch icon2

12
13
14
15
16
17
18
19
20
21
var dns = require('dns')
var net = require('net')
var cluster = require('cluster')
var EOF = uv.UV_EOF
var ECONNRESET = uv.UV_ECONNRESET
var errnoException = util._errnoException
var exceptionWithHostPort = util._exceptionWithHostPort
var dnsOptions = {hints: dns.ADDRCONFIG}

/* istanbul ignore next */
fork icon0
star icon0
watch icon2