mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
lib: fixup incorrect argument order in assertEncoding
PR-URL: https://github.com/nodejs/node/pull/57177 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
22ac5976a8
commit
e28700930d
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
15
test/parallel/test-fs-internal-assertencoding.js
Normal file
15
test/parallel/test-fs-internal-assertencoding.js
Normal file
|
|
@ -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…
Reference in New Issue
Block a user