mirror of
https://github.com/nodejs/node.git
synced 2025-05-07 15:35:41 +00:00

- Moves THROW_AND_RETURN_IF_NOT_BUFFER and THROW_AND_RETURN_IF_NOT_STRING from node_crypto.cc to node_errors.h so it can be reused. - Move THROW_AND_RETURN_UNLESS_BUFFER in util.h to node_buffer.cc and call THROW_AND_RETURN_IF_NOT_BUFFER there. The only other reference to THROW_AND_RETURN_UNLESS_BUFFER in node_i18n.cc can be safely replaced by an assertion since the argument will be checked in JS land. - Migrate ERR_INVALID_ARG_TYPE errors in C++. We can move the checks to JS land if possible later without having to go semver-major. PR-URL: https://github.com/nodejs/node/pull/20121 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
18 lines
476 B
JavaScript
18 lines
476 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const net = require('net');
|
|
|
|
const server = net.createServer().listen(0, common.mustCall(() => {
|
|
const client = net.connect(server.address().port, common.mustCall(() => {
|
|
common.expectsError(() => {
|
|
client.write('broken', 'buffer');
|
|
}, {
|
|
type: TypeError,
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
message: 'Second argument must be a buffer'
|
|
});
|
|
client.destroy();
|
|
server.close();
|
|
}));
|
|
}));
|