Skip to content

Buffer#writeFloat/writeDouble methods don't return an error code yet while the others do #18115

@rogierschouten

Description

@rogierschouten
  • Version: 9.4.0
  • Platform: Windows 10 64-bit
  • Subsystem: buffer.js

Note how the first error has the ERR_INDEX_OUT_OF_RANGE code while the second one doesn't.

$ node
> var b = new Buffer([])
undefined
> b.writeInt8(3)
RangeError [ERR_INDEX_OUT_OF_RANGE]: Index out of range
    at checkInt (buffer.js:1277:11)
    at Buffer.writeInt8 (buffer.js:1442:5)
> b.writeDoubleBE(3)
RangeError: Index out of range
    at Buffer.writeDoubleBE (buffer.js:1533:5)
>

The affected methods are the write float/double LE/BE functions. All others behave correctly.

This complicates error handling unnecessarily and I don't think this is intended behavior. Bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bufferIssues and PRs related to the buffer subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions