Skip to content

napi_throw_error function syntax in Node v8.2.1 and below is different from N-API V1 docs #778

Description

@kanikashah90

In Node v8.2.1 N-API docs syntax for napi_throw_error is:
NODE_EXTERN napi_status napi_throw_error(napi_env env, const char* msg);

Whereas in the latest Node v14 docs syntax is:
NAPI_EXTERN napi_status napi_throw_error(napi_env env, const char* code, const char* msg);
Node v14 docs mention that this method was introduced in N-API version 1 in Node v8.0.0.

code argument is missing in the Node v8.2.1.

When I compile my native add-on compiled using NAPI in Node v8.17.0 it fails to work in Node v8.2.1. And due to syntax differences, the module fails to compile on 8.2.1.

Activity

  1. NickNaso commented on Jul 28, 2020

    @NickNaso
    Member

    Hi @kanikashah90,
    this issue is correlated to this other one #760, now we are updating the documentation in the core through this PR nodejs/node#34344.

    The first version that matches version 1 is 8.6.0. N-API was introduced in version v.8.0.0 as experimental and version 1 continued to evolve until v8.7.0 and therefore the shape of the API in earlier versions is not truly version 1 (in hindsight we should have called it version 0). We recommend version 3 or later.

    Hope that this help you.

  2. gabrielschulhof commented on Aug 3, 2020

    @gabrielschulhof
    Contributor

    The documentation fix to address this issue has landed in core at nodejs/node#34344.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions