Skip to content

Commit 72a2efb

Browse files
author
Gabriel Schulhof
committed
squash: address review comments
1 parent 5f0c112 commit 72a2efb

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/node_api.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ napi_status napi_set_last_error(napi_env env,
2222
void* engine_reserved = nullptr);
2323
void napi_clear_last_error(napi_env env);
2424

25-
struct napi_env__ {
25+
class napi_env__ {
26+
public:
27+
explicit napi_env__(v8::Isolate* _isolate): isolate(_isolate), last_error() {}
28+
~napi_env__() {
29+
last_exception.Reset();
30+
}
2631
v8::Isolate* isolate;
2732
v8::Persistent<v8::Value> last_exception;
2833
napi_extended_error_info last_error;
@@ -533,9 +538,7 @@ void napi_module_register_cb(v8::Local<v8::Object> exports,
533538
// some other framework makes use of slot 0? There really seems to be a need
534539
// for a more robust way of assigning arbitrary data to the isolate.
535540
if (isolate->GetData(0) == nullptr) {
536-
napi_env env = new napi_env__;
537-
env->isolate = isolate;
538-
napi_clear_last_error(env);
541+
napi_env env = new napi_env__(isolate);
539542
isolate->SetData(0, env);
540543
}
541544

0 commit comments

Comments
 (0)