Skip to content

Question about how Error::New() handles last error and exceptions #1089

Closed
@JckXia

Description

@JckXia

I was writing a small Cpp addon trying to see if there exists a scenario where the _ref class variable of Error class might be a nullptr.
TestAddon
Since it looks like the error_code napi_boolean_expected isn't handled by the switch statement inside Error::New().

Though it looks like even though we are able to retrieve the error info using napi_get_last_error_info , once we call napi_is_exception_pending we will clear the last error and thus lose the error info from the previous invocation.
newErrorCode

I am just wondering if this is the expected behaviour? Since it looks like the original error info( a const) is intended to be used elsewhere in the function body. Thanks!

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