Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: correct error.errno to always be numeric #28140

Closed
wants to merge 2 commits into from

Commits on Jun 12, 2019

  1. lib: correct error.errno to always be numeric

    Historically `error.errno` of system errors thrown by Node.js
    can sometimes be the same as `err.code`, which are string
    representations of the error numbers. This is useless and incorrect,
    and results in an information loss for users since then they
    will have to resort to something like
    `process.binding('uv'[`UV_${errno}`])` to get to the numeric
    error codes.
    
    This patch corrects this behavior by always setting `error.errno`
    to be negative numbers. For fabricated errors like `ENOTFOUND`,
    `error.errno` is now undefined since there is no numeric equivalent
    for them anyway. For c-ares errors, `error.errno` is now undefined
    because the numeric representations (negated) can be in conflict
    with libuv error codes - this is fine since numeric codes was
    not available for c-ares errors anyway.
    
    Users can use the public API `util.getSystemErrorName(errno)`
    to retrieve string codes for these numbers.
    joyeecheung committed Jun 12, 2019
    Configuration menu
    Copy the full SHA
    1b55a0e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    6612645 View commit details
    Browse the repository at this point in the history