summaryrefslogtreecommitdiff
path: root/src/fs_event_wrap.cc
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/fs_event_wrap.cc
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/fs_event_wrap.cc')
-rw-r--r--src/fs_event_wrap.cc14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/fs_event_wrap.cc b/src/fs_event_wrap.cc
index a747f71c40..bc3b33027a 100644
--- a/src/fs_event_wrap.cc
+++ b/src/fs_event_wrap.cc
@@ -39,6 +39,7 @@ using v8::FunctionTemplate;
using v8::HandleScope;
using v8::Integer;
using v8::Local;
+using v8::MaybeLocal;
using v8::Object;
using v8::String;
using v8::Value;
@@ -187,17 +188,20 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename,
};
if (filename != nullptr) {
- Local<Value> fn = StringBytes::Encode(env->isolate(),
- filename,
- wrap->encoding_);
+ Local<Value> error;
+ MaybeLocal<Value> fn = StringBytes::Encode(env->isolate(),
+ filename,
+ wrap->encoding_,
+ &error);
if (fn.IsEmpty()) {
argv[0] = Integer::New(env->isolate(), UV_EINVAL);
argv[2] = StringBytes::Encode(env->isolate(),
filename,
strlen(filename),
- BUFFER);
+ BUFFER,
+ &error).ToLocalChecked();
} else {
- argv[2] = fn;
+ argv[2] = fn.ToLocalChecked();
}
}