diff --git a/src/bun.js/bindings/ErrorCode.cpp b/src/bun.js/bindings/ErrorCode.cpp index 35c0c781fe..8ff06a5e73 100644 --- a/src/bun.js/bindings/ErrorCode.cpp +++ b/src/bun.js/bindings/ErrorCode.cpp @@ -1747,7 +1747,7 @@ JSC_DEFINE_HOST_FUNCTION(Bun::jsFunctionMakeErrorWithCode, (JSC::JSGlobalObject } case 2: { JSValue arg0 = callFrame->argument(1); - // ["foo", "bar", "baz"] -> 'The "foo", "bar", or "baz" argument must be specified' + // ["foo", "bar", "baz"] -> 'The "foo" or "bar" or "baz" argument must be specified' if (auto* arr = jsDynamicCast(arg0)) { ASSERT(arr->length() > 0); WTF::StringBuilder builder; @@ -1755,7 +1755,7 @@ JSC_DEFINE_HOST_FUNCTION(Bun::jsFunctionMakeErrorWithCode, (JSC::JSGlobalObject for (unsigned i = 0, length = arr->length(); i < length; i++) { JSValue index = arr->getIndex(globalObject, i); RETURN_IF_EXCEPTION(scope, {}); - if (i == length - 1) builder.append("or "_s); + if (i > 0) builder.append("or "_s); builder.append('"'); auto* jsString = index.toString(globalObject); RETURN_IF_EXCEPTION(scope, {}); @@ -1763,7 +1763,6 @@ JSC_DEFINE_HOST_FUNCTION(Bun::jsFunctionMakeErrorWithCode, (JSC::JSGlobalObject RETURN_IF_EXCEPTION(scope, {}); builder.append(str); builder.append('"'); - if (i != length - 1) builder.append(','); builder.append(' '); } builder.append("argument must be specified"_s); diff --git a/test/js/node/test/parallel/test-net-connect-no-arg.js b/test/js/node/test/parallel/test-net-connect-no-arg.js index 78eb633e73..c795ef7f6e 100644 --- a/test/js/node/test/parallel/test-net-connect-no-arg.js +++ b/test/js/node/test/parallel/test-net-connect-no-arg.js @@ -5,31 +5,31 @@ const assert = require('assert'); const net = require('net'); // Tests that net.connect() called without arguments throws ERR_MISSING_ARGS. -const message = 'The "options", "port", or "path" argument must be specified'; + assert.throws(() => { net.connect(); }, { code: 'ERR_MISSING_ARGS', - message, + message: 'The "options" or "port" or "path" argument must be specified', }); assert.throws(() => { new net.Socket().connect(); }, { code: 'ERR_MISSING_ARGS', - message, + message: 'The "options" or "port" or "path" argument must be specified', }); assert.throws(() => { net.connect({}); }, { code: 'ERR_MISSING_ARGS', - message, + message: 'The "options" or "port" or "path" argument must be specified', }); assert.throws(() => { new net.Socket().connect({}); }, { code: 'ERR_MISSING_ARGS', - message, + message: 'The "options" or "port" or "path" argument must be specified', });