Skip to content

Commit

Permalink
doc: update error code of buffer
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
deokjinkim authored and targos committed May 2, 2023
1 parent b8927dd commit 9101630
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions doc/api/buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,10 @@ It can be constructed in a variety of ways.
<!-- YAML
added: v5.10.0
changes:
- version: v20.0.0
pr-url: https://github.com/nodejs/node/pull/45796
description: Throw ERR_INVALID_ARG_TYPE or ERR_OUT_OF_RANGE instead of
ERR_INVALID_ARG_VALUE for invalid input arguments.
- version: v15.0.0
pr-url: https://github.com/nodejs/node/pull/34682
description: Throw ERR_INVALID_ARG_VALUE instead of ERR_INVALID_OPT_VALUE
Expand Down Expand Up @@ -690,7 +694,7 @@ console.log(buf);
```

If `size` is larger than
[`buffer.constants.MAX_LENGTH`][] or smaller than 0, [`ERR_INVALID_ARG_VALUE`][]
[`buffer.constants.MAX_LENGTH`][] or smaller than 0, [`ERR_OUT_OF_RANGE`][]
is thrown.

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

Allocates a new `Buffer` of `size` bytes. If `size` is larger than
[`buffer.constants.MAX_LENGTH`][] or smaller than 0, [`ERR_INVALID_ARG_VALUE`][]
[`buffer.constants.MAX_LENGTH`][] or smaller than 0, [`ERR_OUT_OF_RANGE`][]
is thrown.

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

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

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

0 comments on commit 9101630

Please sign in to comment.