Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: fix use of deprecated ToObject() #23314

Merged
merged 2 commits into from
Oct 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/exceptions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ Local<Value> UVException(Isolate* isolate,
String::Concat(isolate, js_msg, FIXED_ONE_BYTE_STRING(isolate, "'"));
}

Local<Object> e = Exception::Error(js_msg)->ToObject(isolate);
Local<Object> e =
Exception::Error(js_msg)->ToObject(isolate->GetCurrentContext())
targos marked this conversation as resolved.
Show resolved Hide resolved
.ToLocalChecked();

e->Set(env->errno_string(), Integer::New(isolate, errorno));
e->Set(env->code_string(), js_code);
Expand Down
3 changes: 2 additions & 1 deletion src/node_http_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,8 @@ class Parser : public AsyncWrap, public StreamListener {
enum http_errno err = HTTP_PARSER_ERRNO(&parser_);

Local<Value> e = Exception::Error(env()->parse_error_string());
Local<Object> obj = e->ToObject(env()->isolate());
Local<Object> obj = e->ToObject(env()->isolate()->GetCurrentContext())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@addaleax what about this one?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This scope has an EscapableHandleScope, so maybe it'll be self documenting to use scope.GetIsolate()?

Copy link
Member

@addaleax addaleax Oct 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@targos I think it currently doesn’t matter because we only provide built-in native modules for the main context of an Environment… This would probably the correct choice if we were to change that. On the other hand, using env()->context() might be a tiny bit faster.

This scope has an EscapableHandleScope, so maybe it'll be self documenting to use scope.GetIsolate()?

That would be very unidiomatic.

.ToLocalChecked();
obj->Set(env()->bytes_parsed_string(), nparsed_obj);
obj->Set(env()->code_string(),
OneByteString(env()->isolate(), http_errno_name(err)));
Expand Down