-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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: add ERR_* helpers in C++ and migrates toString() errors in string_bytes.cc #19739
Conversation
cc @addaleax |
src/node_errors.h
Outdated
v8::Local<v8::Object> e = \ | ||
v8::Exception::type(js_msg)->ToObject( \ | ||
isolate->GetCurrentContext()).ToLocalChecked(); \ | ||
e->Set(OneByteString(isolate, "code"), js_code); \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also be the overload that takes a context
argument :)
9dd0222
to
76cc6dc
Compare
Replace the deprecated API with the one that takes the context per suggestion by @addaleax , thanks! |
Looks like on Linux PPCBE we need to ensure an extra copy of memory available for reordering..fixed the test. EDIT: the usage of |
a9fc7b5
to
b416589
Compare
b416589
to
36b46a2
Compare
Currently calling StringBytes::Encode on a UCS2 buffer results in two copies of the buffer and the usage of std::vector::assign makes the memory usage unpredictable, and therefore hard to test against. This patch makes the memory usage more predictable by allocating the memory using node::UncheckedMalloc and handles the memory allocation failure properly. Only one copy of the buffer will be created and it will be freed upon GC of the string. PR-URL: #19798 Refs: #19739 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit adds node::ERR_*(isolate, message) helpers in the C++ land to assign error codes to existing C++ errors. The following errors are added: - ERR_MEMORY_ALLOCATION_FAILED - ERR_STRING_TOO_LARGE
36b46a2
to
6294175
Compare
Landed in 1f29963...63eb267, thanks! |
This commit adds node::ERR_*(isolate, message) helpers in the C++ land to assign error codes to existing C++ errors. The following errors are added: - ERR_MEMORY_ALLOCATION_FAILED - ERR_STRING_TOO_LARGE PR-URL: #19739 Fixes: #3175 Fixes: #9489 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
The old error name and message were trying to be consistent with ERR_BUFFER_TOO_LARGE but they were not really accurate. The kStringMaxLength was measured in number of characters, not number of bytes. The name ERR_STRING_TOO_LARGE also seems a bit awkward. This patch tries to correct them before they get released to users. PR-URL: nodejs#19864 Refs: nodejs#19739 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Currently calling StringBytes::Encode on a UCS2 buffer results in two copies of the buffer and the usage of std::vector::assign makes the memory usage unpredictable, and therefore hard to test against. This patch makes the memory usage more predictable by allocating the memory using node::UncheckedMalloc and handles the memory allocation failure properly. Only one copy of the buffer will be created and it will be freed upon GC of the string. PR-URL: #19798 Refs: #19739 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Another take of #19465 , this one puts the ERR_* helpers in the node namespace and put them inside node_errors.h instead of mingle them with the environment code.
Also fixes the long-standing issue of error messages in
buf.toString
failures by migrating them to the new error system.The first commit is taken from #19738
Fixes: #3175
Fixes: #9489
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes