summaryrefslogtreecommitdiff
path: root/src/string_bytes.h
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2017-04-30 18:53:04 +0200
committerAnna Henningsen <anna@addaleax.net>2017-05-03 19:21:32 +0200
commitd56a7e640f766f15980b28d15bbf02bf60975ab2 (patch)
treed50b7da36ca2331cabe23da90d55d4dcf77ea74f /src/string_bytes.h
parent6c2daf0ce9cffbadf51359ddfb804f5a6107737c (diff)
downloadandroid-node-v8-d56a7e640f766f15980b28d15bbf02bf60975ab2.tar.gz
android-node-v8-d56a7e640f766f15980b28d15bbf02bf60975ab2.tar.bz2
android-node-v8-d56a7e640f766f15980b28d15bbf02bf60975ab2.zip
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>
Diffstat (limited to 'src/string_bytes.h')
-rw-r--r--src/string_bytes.h25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/string_bytes.h b/src/string_bytes.h
index 81561e6e70..e11c16d65f 100644
--- a/src/string_bytes.h
+++ b/src/string_bytes.h
@@ -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::Local<v8::Value> Encode(v8::Isolate* isolate,
- const char* buf,
- enum encoding encoding);
+ static v8::MaybeLocal<v8::Value> Encode(v8::Isolate* isolate,
+ const uint16_t* buf,
+ size_t buflen,
+ v8::Local<v8::Value>* error);
+
+ 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,