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: nodejs#45796
PR-URL: nodejs#47617
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
deokjinkim authored and MoLow committed Jul 6, 2023
1 parent d6b555e commit 971c545
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 @@ -642,6 +642,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 @@ -688,7 +692,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 @@ -745,6 +749,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 @@ -757,7 +765,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 @@ -815,6 +823,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 @@ -824,7 +836,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 @@ -5465,7 +5477,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 971c545

Please sign in to comment.