Skip to content

std::exception not caught #1225

@froody

Description

@froody

The documentation states "On return from a native method, node-addon-api will automatically convert a pending C++ exception to a JavaScript exception." but in InstanceMethodCallbackWrapper when I call a C++ API that throws std::exception, std::terminate is called because no exception handler is installed. If I wrap my call in something like

try {
   my_api();
} catch (const std::exception &e) {
  Napi::Error::New(info.Env(), e.what()).ThrowAsJavaScriptException();
}

Then the exceptions are passed up to javascript, but based on my reading of the documentation I shouldn't need to do this.

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