mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
src: do proper StringBytes error handling
- Return `MaybeLocal`s from `StringBytes::Encode` - Add an `error` out parameter to pass JS exceptions to the callers (instead of directly throwing) - Simplify some of the string generation methods in `string_bytes.cc` by unifying the `EXTERN_APEX` logic - Reduce usage of deprecated V8 APIs. - Remove error handling logic from JS, the `buffer.*Slice()` methods now throw errors themselves. - Left TODO comments for future semver-major error message improvements. This paves the way for better error messages coming out of the StringBytes methods. Ref: https://github.com/nodejs/node/issues/3175 PR-URL: https://github.com/nodejs/node/pull/12765 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
This commit is contained in:
9 files changed
+325
-188
No files matched your search
+13
-10
@@ -105,19 +105,22 @@ class StringBytes {
|
||||
|
||||
// Take the bytes in the src, and turn it into a Buffer or String.
|
||||
// Don't call with encoding=UCS2.
|
||||
static v8::Local<v8::Value> Encode(v8::Isolate* isolate,
|
||||
const char* buf,
|
||||
size_t buflen,
|
||||
enum encoding encoding);
|
||||
static v8::MaybeLocal<v8::Value> Encode(v8::Isolate* isolate,
|
||||
const char* buf,
|
||||
size_t buflen,
|
||||
enum encoding encoding,
|
||||
v8::Local<v8::Value>* error);
|
||||
|
||||
// The input buffer should be in host endianness.
|
||||
static v8::Local<v8::Value> Encode(v8::Isolate* isolate,
|
||||
const uint16_t* buf,
|
||||
size_t buflen);
|
||||
static v8::MaybeLocal<v8::Value> Encode(v8::Isolate* isolate,
|
||||
const uint16_t* buf,
|
||||
size_t buflen,
|
||||
v8::Local<v8::Value>* error);
|
||||
|
||||
static v8::Local<v8::Value> Encode(v8::Isolate* isolate,
|
||||
const char* buf,
|
||||
enum encoding encoding);
|
||||
static v8::MaybeLocal<v8::Value> Encode(v8::Isolate* isolate,
|
||||
const char* buf,
|
||||
enum encoding encoding,
|
||||
v8::Local<v8::Value>* error);
|
||||
|
||||
private:
|
||||
static size_t WriteUCS2(char* buf,
|
||||
|
||||
Reference in new issue
Block a user