Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/internal/fs/recursive_watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class FSWatcher extends EventEmitter {
if (encoding != null) {
// This is required since on macOS and Windows it throws ERR_INVALID_ARG_VALUE
if (typeof encoding !== 'string') {
throw new ERR_INVALID_ARG_VALUE(encoding, 'options.encoding');
throw new ERR_INVALID_ARG_VALUE('options.encoding', encoding);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/internal/fs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function lazyLoadFs() {
function assertEncoding(encoding) {
if (encoding && !Buffer.isEncoding(encoding)) {
const reason = 'is invalid encoding';
throw new ERR_INVALID_ARG_VALUE(encoding, 'encoding', reason);
throw new ERR_INVALID_ARG_VALUE('encoding', encoding, reason);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/internal/fs/watchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ async function* watch(filename, options = kEmptyObject) {

if (encoding && !isEncoding(encoding)) {
const reason = 'is invalid encoding';
throw new ERR_INVALID_ARG_VALUE(encoding, 'encoding', reason);
throw new ERR_INVALID_ARG_VALUE('encoding', encoding, reason);
}

if (signal?.aborted)
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/quic/quic.js
Original file line number Diff line number Diff line change
Expand Up @@ -2069,7 +2069,7 @@ function processSessionOptions(options, forServer = false) {
if (cc !== undefined) {
validateString(cc, 'options.cc');
if (cc !== 'reno' || cc !== 'bbr' || cc !== 'cubic') {
throw new ERR_INVALID_ARG_VALUE(cc, 'options.cc');
throw new ERR_INVALID_ARG_VALUE('options.cc', cc);
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/internal/webstreams/adapters.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ function newStreamReadableFromReadableStream(readableStream, options = kEmptyObj
} = options;

if (encoding !== undefined && !Buffer.isEncoding(encoding))
throw new ERR_INVALID_ARG_VALUE(encoding, 'options.encoding');
throw new ERR_INVALID_ARG_VALUE('options.encoding', encoding);
validateBoolean(objectMode, 'options.objectMode');

const reader = readableStream.getReader();
Expand Down Expand Up @@ -686,7 +686,7 @@ function newStreamDuplexFromReadableWritablePair(pair = kEmptyObject, options =

validateBoolean(objectMode, 'options.objectMode');
if (encoding !== undefined && !Buffer.isEncoding(encoding))
throw new ERR_INVALID_ARG_VALUE(encoding, 'options.encoding');
throw new ERR_INVALID_ARG_VALUE('options.encoding', encoding);

const writer = writableStream.getWriter();
const reader = readableStream.getReader();
Expand Down
15 changes: 15 additions & 0 deletions test/parallel/test-fs-internal-assertencoding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

// Tests to verify that a correctly formatted invalid encoding error
// is thrown. Originally the internal assertEncoding utility was
// reversing the arguments when constructing the ERR_INVALID_ARG_VALUE
// error.

require('../common');
const { opendirSync } = require('node:fs');
const { throws } = require('node:assert');

throws(() => opendirSync('.', { encoding: 'no' }), {
code: 'ERR_INVALID_ARG_VALUE',
message: 'The argument \'encoding\' is invalid encoding. Received \'no\'',
});
Loading