mirror of https://github.com/lukechilds/node.git
Browse Source
Replace var to const/let, use common.mustCall on callbacks and move process.on('exit') to the .on('error') handler PR-URL: https://github.com/nodejs/node/pull/10025 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>v6
Julian Duque
8 years ago
committed by
James M Snell
1 changed files with 10 additions and 18 deletions
@ -1,20 +1,12 @@ |
|||||
'use strict'; |
'use strict'; |
||||
var common = require('../common'); |
const common = require('../common'); |
||||
var assert = require('assert'); |
const assert = require('assert'); |
||||
var net = require('net'); |
const net = require('net'); |
||||
|
|
||||
var gotError = false; |
// This should fail with an async EINVAL error, not throw an exception
|
||||
|
net.createServer(common.fail) |
||||
process.on('exit', function() { |
.listen({fd: 0}) |
||||
assert(gotError instanceof Error); |
.on('error', common.mustCall(function(e) { |
||||
}); |
assert(e instanceof Error); |
||||
|
assert(['EINVAL', 'ENOTSOCK'].includes(e.code)); |
||||
// this should fail with an async EINVAL error, not throw an exception
|
})); |
||||
net.createServer(common.fail).listen({fd: 0}).on('error', function(e) { |
|
||||
switch (e.code) { |
|
||||
case 'EINVAL': |
|
||||
case 'ENOTSOCK': |
|
||||
gotError = e; |
|
||||
break; |
|
||||
} |
|
||||
}); |
|
||||
|
Loading…
Reference in new issue