net: migrate errors to internal/errors

Throw ERR_SOCKET_CLOSED and ERR_SERVER_NOT_RUNNING
instead of the old-style errors in net.js.

PR-URL: https://github.com/nodejs/node/pull/17766
Refs: https://github.com/nodejs/node/issues/17709
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
kysnm 2017-12-20 08:07:41 +09:00 committed by Joyee Cheung
parent 8599465d33
commit b98aaa312e
No known key found for this signature in database
GPG key ID: F586868AAD831D0C
6 changed files with 31 additions and 13 deletions

View file

@ -58,8 +58,10 @@ server.listen(common.PIPE, common.mustCall(function() {
assert.strictEqual(res.body, 'hello world\n');
server.close(common.mustCall(function(error) {
assert.strictEqual(error, undefined);
server.close(common.mustCall(function(error) {
assert.strictEqual(error && error.message, 'Not running');
server.close(common.expectsError({
code: 'ERR_SERVER_NOT_RUNNING',
message: 'Server is not running.',
type: Error
}));
}));
}));