diff options
author | Brian White <mscdex@mscdex.net> | 2015-12-15 03:55:35 -0500 |
---|---|---|
committer | Brian White <mscdex@mscdex.net> | 2015-12-19 14:15:38 -0500 |
commit | 18490d3d5af3131751791e501302bc57865337b3 (patch) | |
tree | 78cb704b8126394b9b632484ca7bde17a06914e3 /src/node_util.cc | |
parent | 4b0b991bf5bbb41e204a7b98f62a8afd00faf855 (diff) | |
download | android-node-v8-18490d3d5af3131751791e501302bc57865337b3.tar.gz android-node-v8-18490d3d5af3131751791e501302bc57865337b3.tar.bz2 android-node-v8-18490d3d5af3131751791e501302bc57865337b3.zip |
module: always decorate thrown errors
This provides more information when encountering a syntax or similar
error when executing a file with require().
Fixes: https://github.com/nodejs/node/issues/4286
PR-URL: https://github.com/nodejs/node/pull/4287
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'src/node_util.cc')
-rw-r--r-- | src/node_util.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/node_util.cc b/src/node_util.cc index 1e0f214ae4..8475468c1f 100644 --- a/src/node_util.cc +++ b/src/node_util.cc @@ -52,6 +52,21 @@ static void GetHiddenValue(const FunctionCallbackInfo<Value>& args) { args.GetReturnValue().Set(obj->GetHiddenValue(name)); } +static void SetHiddenValue(const FunctionCallbackInfo<Value>& args) { + Environment* env = Environment::GetCurrent(args); + + if (!args[0]->IsObject()) + return env->ThrowTypeError("obj must be an object"); + + if (!args[1]->IsString()) + return env->ThrowTypeError("name must be a string"); + + Local<Object> obj = args[0].As<Object>(); + Local<String> name = args[1].As<String>(); + + args.GetReturnValue().Set(obj->SetHiddenValue(name, args[2])); +} + void Initialize(Local<Object> target, Local<Value> unused, @@ -63,6 +78,7 @@ void Initialize(Local<Object> target, #undef V env->SetMethod(target, "getHiddenValue", GetHiddenValue); + env->SetMethod(target, "setHiddenValue", SetHiddenValue); } } // namespace util |