summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDolapo Toki <dolapotoki@gmail.com>2018-10-12 11:11:44 -0700
committerAnna Henningsen <anna@addaleax.net>2018-10-16 13:46:30 +0200
commit91fe7e5ad28a7bc75948f380a051aae156131b37 (patch)
treeeeb5c67d90ad61511da1276759e06f28a23e161f /src
parentc34eae5f882c8bb4d58b492caf97cdb08b1dbbcb (diff)
downloadandroid-node-v8-91fe7e5ad28a7bc75948f380a051aae156131b37.tar.gz
android-node-v8-91fe7e5ad28a7bc75948f380a051aae156131b37.tar.bz2
android-node-v8-91fe7e5ad28a7bc75948f380a051aae156131b37.zip
src: add deprecation warning to errname()
PR-URL: https://github.com/nodejs/node/pull/23597 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/env.cc1
-rw-r--r--src/env.h7
-rw-r--r--src/uv.cc11
3 files changed, 17 insertions, 2 deletions
diff --git a/src/env.cc b/src/env.cc
index 14a8b23a84..4f98b5590c 100644
--- a/src/env.cc
+++ b/src/env.cc
@@ -134,6 +134,7 @@ Environment::Environment(IsolateData* isolate_data,
printed_error_(false),
abort_on_uncaught_exception_(false),
emit_env_nonstring_warning_(true),
+ emit_err_name_warning_(true),
makecallback_cntr_(0),
should_abort_on_uncaught_toggle_(isolate_, 1),
trace_category_state_(isolate_, kTraceCategoryCount),
diff --git a/src/env.h b/src/env.h
index 1eb333b0ef..3daa48f9cb 100644
--- a/src/env.h
+++ b/src/env.h
@@ -843,6 +843,12 @@ class Environment {
return current_value;
}
+ inline bool EmitErrNameWarning() {
+ bool current_value = emit_err_name_warning_;
+ emit_err_name_warning_ = false;
+ return current_value;
+ }
+
typedef void (*native_immediate_callback)(Environment* env, void* data);
// cb will be called as cb(env, data) on the next event loop iteration.
// obj will be kept alive between now and after the callback has run.
@@ -929,6 +935,7 @@ class Environment {
bool printed_error_;
bool abort_on_uncaught_exception_;
bool emit_env_nonstring_warning_;
+ bool emit_err_name_warning_;
size_t makecallback_cntr_;
std::vector<double> destroy_async_id_list_;
diff --git a/src/uv.cc b/src/uv.cc
index 3d070a32bd..354acee4c0 100644
--- a/src/uv.cc
+++ b/src/uv.cc
@@ -39,10 +39,17 @@ using v8::String;
using v8::Value;
-// TODO(joyeecheung): deprecate this function in favor of
-// lib/util.getSystemErrorName()
void ErrName(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
+ if (env->options()->pending_deprecation && env->EmitErrNameWarning()) {
+ if (ProcessEmitDeprecationWarning(
+ env,
+ "Directly calling process.binding('uv').errname(<val>) is being"
+ " deprecated. "
+ "Please make sure to use util.getSystemErrorName() instead.",
+ "DEP0119").IsNothing())
+ return;
+ }
int err;
if (!args[0]->Int32Value(env->context()).To(&err)) return;
CHECK_LT(err, 0);