Skip to content

Commit 971c545

Browse files
deokjinkimMoLow
authored andcommitted
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 <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent d6b555e commit 971c545

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
@@ -642,6 +642,10 @@ It can be constructed in a variety of ways.
642642
<!-- YAML
643643
added: v5.10.0
644644
changes:
645+
- version: v20.0.0
646+
pr-url: https://github.com/nodejs/node/pull/45796
647+
description: Throw ERR_INVALID_ARG_TYPE or ERR_OUT_OF_RANGE instead of
648+
ERR_INVALID_ARG_VALUE for invalid input arguments.
645649
- version: v15.0.0
646650
pr-url: https://github.com/nodejs/node/pull/34682
647651
description: Throw ERR_INVALID_ARG_VALUE instead of ERR_INVALID_OPT_VALUE
@@ -688,7 +692,7 @@ console.log(buf);
688692
```
689693

690694
If `size` is larger than
691-
[`buffer.constants.MAX_LENGTH`][] or smaller than 0, [`ERR_INVALID_ARG_VALUE`][]
695+
[`buffer.constants.MAX_LENGTH`][] or smaller than 0, [`ERR_OUT_OF_RANGE`][]
692696
is thrown.
693697

694698
If `fill` is specified, the allocated `Buffer` will be initialized by calling
@@ -745,6 +749,10 @@ A `TypeError` will be thrown if `size` is not a number.
745749
<!-- YAML
746750
added: v5.10.0
747751
changes:
752+
- version: v20.0.0
753+
pr-url: https://github.com/nodejs/node/pull/45796
754+
description: Throw ERR_INVALID_ARG_TYPE or ERR_OUT_OF_RANGE instead of
755+
ERR_INVALID_ARG_VALUE for invalid input arguments.
748756
- version: v15.0.0
749757
pr-url: https://github.com/nodejs/node/pull/34682
750758
description: Throw ERR_INVALID_ARG_VALUE instead of ERR_INVALID_OPT_VALUE
@@ -757,7 +765,7 @@ changes:
757765
* `size` {integer} The desired length of the new `Buffer`.
758766

759767
Allocates a new `Buffer` of `size` bytes. If `size` is larger than
760-
[`buffer.constants.MAX_LENGTH`][] or smaller than 0, [`ERR_INVALID_ARG_VALUE`][]
768+
[`buffer.constants.MAX_LENGTH`][] or smaller than 0, [`ERR_OUT_OF_RANGE`][]
761769
is thrown.
762770

763771
The underlying memory for `Buffer` instances created in this way is _not
@@ -815,6 +823,10 @@ additional performance that [`Buffer.allocUnsafe()`][] provides.
815823
<!-- YAML
816824
added: v5.12.0
817825
changes:
826+
- version: v20.0.0
827+
pr-url: https://github.com/nodejs/node/pull/45796
828+
description: Throw ERR_INVALID_ARG_TYPE or ERR_OUT_OF_RANGE instead of
829+
ERR_INVALID_ARG_VALUE for invalid input arguments.
818830
- version: v15.0.0
819831
pr-url: https://github.com/nodejs/node/pull/34682
820832
description: Throw ERR_INVALID_ARG_VALUE instead of ERR_INVALID_OPT_VALUE
@@ -824,7 +836,7 @@ changes:
824836
* `size` {integer} The desired length of the new `Buffer`.
825837

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

830842
The underlying memory for `Buffer` instances created in this way is _not
@@ -5465,7 +5477,6 @@ introducing security vulnerabilities into an application.
54655477
[`Buffer.from(string)`]: #static-method-bufferfromstring-encoding
54665478
[`Buffer.poolSize`]: #class-property-bufferpoolsize
54675479
[`DataView`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
5468-
[`ERR_INVALID_ARG_VALUE`]: errors.md#err_invalid_arg_value
54695480
[`ERR_INVALID_BUFFER_SIZE`]: errors.md#err_invalid_buffer_size
54705481
[`ERR_OUT_OF_RANGE`]: errors.md#err_out_of_range
54715482
[`File`]: https://developer.mozilla.org/en-US/docs/Web/API/File

0 commit comments

Comments
 (0)