summaryrefslogtreecommitdiff
path: root/src/uv.cc
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2017-08-18 15:37:35 -0700
committerJames M Snell <jasnell@gmail.com>2017-08-23 10:51:15 -0700
commit58831b2f24a6b71b172e5f5876cb77096408142e (patch)
treeaff51623b82e17dbc63f48ad1b6692a6f09bf70c /src/uv.cc
parent5e7c69716ecbb7a0ebceaed7cc1c6847f9bc5058 (diff)
downloadnode-new-58831b2f24a6b71b172e5f5876cb77096408142e.tar.gz
uv: improvements to process.binding('uv')
* ensure that UV_... props are constants * improve error message ... the error message when passing in `err >= 0` to `util._errnoException()` was less than useful. * refine uses of process.binding('uv') PR-URL: https://github.com/nodejs/node/pull/14933 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'src/uv.cc')
-rw-r--r--src/uv.cc9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/uv.cc b/src/uv.cc
index 3e345374a2..260aae92a7 100644
--- a/src/uv.cc
+++ b/src/uv.cc
@@ -29,7 +29,6 @@ namespace {
using v8::Context;
using v8::FunctionCallbackInfo;
-using v8::Integer;
using v8::Local;
using v8::Object;
using v8::Value;
@@ -38,8 +37,7 @@ using v8::Value;
void ErrName(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
int err = args[0]->Int32Value();
- if (err >= 0)
- return env->ThrowError("err >= 0");
+ CHECK_LT(err, 0);
const char* name = uv_err_name(err);
args.GetReturnValue().Set(OneByteString(env->isolate(), name));
}
@@ -51,9 +49,8 @@ void InitializeUV(Local<Object> target,
Environment* env = Environment::GetCurrent(context);
target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "errname"),
env->NewFunctionTemplate(ErrName)->GetFunction());
-#define V(name, _) \
- target->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "UV_" # name), \
- Integer::New(env->isolate(), UV_ ## name));
+
+#define V(name, _) NODE_DEFINE_CONSTANT(target, UV_##name);
UV_ERRNO_MAP(V)
#undef V
}