summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2013-03-05 17:46:37 -0800
committerisaacs <i@izs.me>2013-03-06 11:44:29 -0800
commit5038f4018534f498734fc39ef1bcd72650a3e7e2 (patch)
tree6fb5795ded2af9182b0542614c8cbb6bed0ed32a
parent25ba971f41d4ddaf7e241645cfc2917bd3afa1f7 (diff)
downloadandroid-node-v8-5038f4018534f498734fc39ef1bcd72650a3e7e2.tar.gz
android-node-v8-5038f4018534f498734fc39ef1bcd72650a3e7e2.tar.bz2
android-node-v8-5038f4018534f498734fc39ef1bcd72650a3e7e2.zip
node: Add --throw-deprecation
Extremely handy when tracking down a flood of recursive nextTick warnings.
-rw-r--r--doc/node.12
-rw-r--r--lib/util.js4
-rw-r--r--src/node.cc9
-rw-r--r--src/node.js4
4 files changed, 17 insertions, 2 deletions
diff --git a/doc/node.1 b/doc/node.1
index 9603a91ef0..1bc4ee04c1 100644
--- a/doc/node.1
+++ b/doc/node.1
@@ -56,6 +56,8 @@ and servers.
--trace-deprecation show stack traces on deprecations
+ --throw-deprecation throw errors on deprecations
+
--v8-options print v8 command line options
--max-stack-size=val set max v8 stack size (bytes)
diff --git a/lib/util.js b/lib/util.js
index a71876adbd..40b0680b37 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -65,7 +65,9 @@ exports.deprecate = function(fn, msg) {
var warned = false;
function deprecated() {
if (!warned) {
- if (process.traceDeprecation) {
+ if (process.throwDeprecation) {
+ throw new Error(msg);
+ } else if (process.traceDeprecation) {
console.trace(msg);
} else {
console.error(msg);
diff --git a/src/node.cc b/src/node.cc
index 279bb0c05b..6388a11c91 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -127,6 +127,7 @@ static Persistent<String> disposed_symbol;
static bool print_eval = false;
static bool force_repl = false;
static bool trace_deprecation = false;
+static bool throw_deprecation = false;
static char *eval_string = NULL;
static int option_end_index = 0;
static bool use_debug_agent = false;
@@ -2414,6 +2415,11 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
process->Set(String::NewSymbol("noDeprecation"), True());
}
+ // --throw-deprecation
+ if (throw_deprecation) {
+ process->Set(String::NewSymbol("throwDeprecation"), True());
+ }
+
// --trace-deprecation
if (trace_deprecation) {
process->Set(String::NewSymbol("traceDeprecation"), True());
@@ -2666,6 +2672,9 @@ static void ParseArgs(int argc, char **argv) {
} else if (strcmp(arg, "--trace-deprecation") == 0) {
argv[i] = const_cast<char*>("");
trace_deprecation = true;
+ } else if (strcmp(arg, "--throw-deprecation") == 0) {
+ argv[i] = const_cast<char*>("");
+ throw_deprecation = true;
} else if (argv[i][0] != '-') {
break;
}
diff --git a/src/node.js b/src/node.js
index c0c62e265b..e37fda2f92 100644
--- a/src/node.js
+++ b/src/node.js
@@ -359,7 +359,9 @@
var msg = '(node) warning: Recursive process.nextTick detected. ' +
'This will break in the next version of node. ' +
'Please use setImmediate for recursive deferral.';
- if (process.traceDeprecation)
+ if (process.throwDeprecation)
+ throw new Error(msg);
+ else if (process.traceDeprecation)
console.trace(msg);
else
console.error(msg);