Skip to content

Commit

Permalink
fix(core): add handle_scope for v8 exception (#2860)
Browse files Browse the repository at this point in the history
  • Loading branch information
churchill-zhang authored and zoomchan-cxj committed Feb 24, 2023
1 parent 99c3f54 commit 48e38c8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/src/napi/v8/js_native_api_v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,12 @@ void V8TryCatch::SetVerbose(bool verbose) {

std::shared_ptr<CtxValue> V8TryCatch::Exception() {
if (try_catch_) {
v8::Local<v8::Value> exception = try_catch_->Exception();
std::shared_ptr<V8Ctx> v8_ctx = std::static_pointer_cast<V8Ctx>(ctx_);
TDF_BASE_CHECK(ctx_);
auto v8_ctx = std::static_pointer_cast<V8Ctx>(ctx_);
v8::HandleScope handle_scope(v8_ctx->isolate_);
auto context = v8_ctx->context_persistent_.Get(v8_ctx->isolate_);
v8::Context::Scope context_scope(context);
auto exception = try_catch_->Exception();
return std::make_shared<V8CtxValue>(v8_ctx->isolate_, exception);
}
return nullptr;
Expand Down

0 comments on commit 48e38c8

Please sign in to comment.