Skip to content

Commit

Permalink
worker: mention argument name in type check message
Browse files Browse the repository at this point in the history
Refs: #32745 (comment)

PR-URL: #32815
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
  • Loading branch information
addaleax authored and MylesBorins committed Apr 17, 2020
1 parent 2662b0c commit 7fe6122
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/node_messaging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ void MessagePort::ReceiveMessage(const FunctionCallbackInfo<Value>& args) {
if (!args[0]->IsObject() ||
!env->message_port_constructor_template()->HasInstance(args[0])) {
return THROW_ERR_INVALID_ARG_TYPE(env,
"First argument needs to be a MessagePort instance");
"The \"port\" argument must be a MessagePort instance");
}
MessagePort* port = Unwrap<MessagePort>(args[0].As<Object>());
if (port == nullptr) {
Expand All @@ -890,7 +890,7 @@ void MessagePort::MoveToContext(const FunctionCallbackInfo<Value>& args) {
if (!args[0]->IsObject() ||
!env->message_port_constructor_template()->HasInstance(args[0])) {
return THROW_ERR_INVALID_ARG_TYPE(env,
"First argument needs to be a MessagePort instance");
"The \"port\" argument must be a MessagePort instance");
}
MessagePort* port = Unwrap<MessagePort>(args[0].As<Object>());
CHECK_NOT_NULL(port);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-worker-message-port-receive-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ for (const value of [null, 0, -1, {}, []]) {
assert.throws(() => receiveMessageOnPort(value), {
name: 'TypeError',
code: 'ERR_INVALID_ARG_TYPE',
message: 'First argument needs to be a MessagePort instance'
message: 'The "port" argument must be a MessagePort instance'
});
}

0 comments on commit 7fe6122

Please sign in to comment.