Skip to content

Commit eb17645

Browse files
authored
doc: update error code of buffer
According to use of `validateNumber`, error code is changed from ERR_INVALID_ARG_VALUE to ERR_OUT_OF_RANGE. Refs: #45796 PR-URL: #47617 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 472ffde commit eb17645

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

doc/api/buffer.md

+15-4
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,10 @@ It can be constructed in a variety of ways.
644644
<!-- YAML
645645
added: v5.10.0
646646
changes:
647+
- version: v20.0.0
648+
pr-url: https://github.com/nodejs/node/pull/45796
649+
description: Throw ERR_INVALID_ARG_TYPE or ERR_OUT_OF_RANGE instead of
650+
ERR_INVALID_ARG_VALUE for invalid input arguments.
647651
- version: v15.0.0
648652
pr-url: https://github.com/nodejs/node/pull/34682
649653
description: Throw ERR_INVALID_ARG_VALUE instead of ERR_INVALID_OPT_VALUE
@@ -690,7 +694,7 @@ console.log(buf);
690694
```
691695

692696
If `size` is larger than
693-
[`buffer.constants.MAX_LENGTH`][] or smaller than 0, [`ERR_INVALID_ARG_VALUE`][]
697+
[`buffer.constants.MAX_LENGTH`][] or smaller than 0, [`ERR_OUT_OF_RANGE`][]
694698
is thrown.
695699

696700
If `fill` is specified, the allocated `Buffer` will be initialized by calling
@@ -747,6 +751,10 @@ A `TypeError` will be thrown if `size` is not a number.
747751
<!-- YAML
748752
added: v5.10.0
749753
changes:
754+
- version: v20.0.0
755+
pr-url: https://github.com/nodejs/node/pull/45796
756+
description: Throw ERR_INVALID_ARG_TYPE or ERR_OUT_OF_RANGE instead of
757+
ERR_INVALID_ARG_VALUE for invalid input arguments.
750758
- version: v15.0.0
751759
pr-url: https://github.com/nodejs/node/pull/34682
752760
description: Throw ERR_INVALID_ARG_VALUE instead of ERR_INVALID_OPT_VALUE
@@ -759,7 +767,7 @@ changes:
759767
* `size` {integer} The desired length of the new `Buffer`.
760768

761769
Allocates a new `Buffer` of `size` bytes. If `size` is larger than
762-
[`buffer.constants.MAX_LENGTH`][] or smaller than 0, [`ERR_INVALID_ARG_VALUE`][]
770+
[`buffer.constants.MAX_LENGTH`][] or smaller than 0, [`ERR_OUT_OF_RANGE`][]
763771
is thrown.
764772

765773
The underlying memory for `Buffer` instances created in this way is _not
@@ -817,6 +825,10 @@ additional performance that [`Buffer.allocUnsafe()`][] provides.
817825
<!-- YAML
818826
added: v5.12.0
819827
changes:
828+
- version: v20.0.0
829+
pr-url: https://github.com/nodejs/node/pull/45796
830+
description: Throw ERR_INVALID_ARG_TYPE or ERR_OUT_OF_RANGE instead of
831+
ERR_INVALID_ARG_VALUE for invalid input arguments.
820832
- version: v15.0.0
821833
pr-url: https://github.com/nodejs/node/pull/34682
822834
description: Throw ERR_INVALID_ARG_VALUE instead of ERR_INVALID_OPT_VALUE
@@ -826,7 +838,7 @@ changes:
826838
* `size` {integer} The desired length of the new `Buffer`.
827839

828840
Allocates a new `Buffer` of `size` bytes. If `size` is larger than
829-
[`buffer.constants.MAX_LENGTH`][] or smaller than 0, [`ERR_INVALID_ARG_VALUE`][]
841+
[`buffer.constants.MAX_LENGTH`][] or smaller than 0, [`ERR_OUT_OF_RANGE`][]
830842
is thrown. A zero-length `Buffer` is created if `size` is 0.
831843

832844
The underlying memory for `Buffer` instances created in this way is _not
@@ -5485,7 +5497,6 @@ introducing security vulnerabilities into an application.
54855497
[`Buffer.from(string)`]: #static-method-bufferfromstring-encoding
54865498
[`Buffer.poolSize`]: #class-property-bufferpoolsize
54875499
[`DataView`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
5488-
[`ERR_INVALID_ARG_VALUE`]: errors.md#err_invalid_arg_value
54895500
[`ERR_INVALID_BUFFER_SIZE`]: errors.md#err_invalid_buffer_size
54905501
[`ERR_OUT_OF_RANGE`]: errors.md#err_out_of_range
54915502
[`File`]: https://developer.mozilla.org/en-US/docs/Web/API/File

0 commit comments

Comments
 (0)