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>
This commit is contained in:
parent
c34eae5f88
commit
91fe7e5ad2
@ -2233,6 +2233,21 @@ like `dns.lookup(false)` due to backward compatibility.
|
||||
This behavior is undocumented and is thought to be unused in real world apps.
|
||||
It will become an error in future versions of Node.js.
|
||||
|
||||
<a id="DEP0119"></a>
|
||||
### DEP0119: process.binding('uv').errname() private API
|
||||
<!--
|
||||
changes:
|
||||
- version: REPLACEME
|
||||
pr-url: https://github.com/nodejs/node/pull/23597
|
||||
description: Documentation-only deprecation.
|
||||
-->
|
||||
|
||||
Type: Documentation-only (supports [`--pending-deprecation`][])
|
||||
|
||||
Directly calling `process.binding('uv').errname(<val>)` is deprecated.
|
||||
Please make sure to use [`util.getSystemErrorName()`][] instead.
|
||||
|
||||
|
||||
[`--pending-deprecation`]: cli.html#cli_pending_deprecation
|
||||
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
|
||||
[`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array
|
||||
@ -2300,6 +2315,7 @@ It will become an error in future versions of Node.js.
|
||||
[`util._extend()`]: util.html#util_util_extend_target_source
|
||||
[`util.debug()`]: util.html#util_util_debug_string
|
||||
[`util.error()`]: util.html#util_util_error_strings
|
||||
[`util.getSystemErrorName()`]: util.html#util_util_getsystemerrorname_err
|
||||
[`util.inspect()`]: util.html#util_util_inspect_object_options
|
||||
[`util.inspect.custom`]: util.html#util_util_inspect_custom
|
||||
[`util.isArray()`]: util.html#util_util_isarray_object
|
||||
|
@ -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),
|
||||
|
@ -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_;
|
||||
|
||||
|
11
src/uv.cc
11
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);
|
||||
|
13
test/parallel/test-err-name-deprecation.js
Normal file
13
test/parallel/test-err-name-deprecation.js
Normal file
@ -0,0 +1,13 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
|
||||
// Flags: --pending-deprecation
|
||||
|
||||
common.expectWarning(
|
||||
'DeprecationWarning',
|
||||
'Directly calling process.binding(\'uv\').errname(<val>) is being ' +
|
||||
'deprecated. Please make sure to use util.getSystemErrorName() instead.',
|
||||
'DEP0119'
|
||||
);
|
||||
|
||||
process.binding('uv').errname(-1);
|
Loading…
x
Reference in New Issue
Block a user