summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2013-03-13 14:59:42 -0700
committerisaacs <i@izs.me>2013-03-13 15:34:18 -0700
commit6bd8b7e5405e1cdc9f56214f5f6b741806c32e5f (patch)
tree6722c868e6469202d0ae1d798b4315c98c43ebfe /lib
parentfa05e8a2706e20a191942fe2b2273481605a1f14 (diff)
downloadandroid-node-v8-6bd8b7e5405e1cdc9f56214f5f6b741806c32e5f.tar.gz
android-node-v8-6bd8b7e5405e1cdc9f56214f5f6b741806c32e5f.tar.bz2
android-node-v8-6bd8b7e5405e1cdc9f56214f5f6b741806c32e5f.zip
fs: Missing cb errors are deprecated, not a throw
Commit a804347 makes fs function rethrow errors when the callback is omitted. While the right thing to do, it's a change from the old v0.8 behavior where such errors were silently ignored. To give users time to upgrade, temporarily disable that and replace it with a function that warns once about the deprecated behavior. Close #5005
Diffstat (limited to 'lib')
-rw-r--r--lib/fs.js34
1 files changed, 24 insertions, 10 deletions
diff --git a/lib/fs.js b/lib/fs.js
index 3d37a648a7..49bb027376 100644
--- a/lib/fs.js
+++ b/lib/fs.js
@@ -59,22 +59,36 @@ var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
function rethrow() {
// Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and
// is fairly slow to generate.
+ var callback;
if (DEBUG) {
var backtrace = new Error;
- return function(err) {
- if (err) {
- backtrace.message = err.message;
- err = backtrace;
- throw err;
- }
- };
+ callback = debugCallback;
+ } else
+ callback = missingCallback;
+
+ return callback;
+
+ function debugCallback(err) {
+ if (err) {
+ backtrace.message = err.message;
+ err = backtrace;
+ missingCallback(err);
+ }
}
- return function(err) {
+ function missingCallback(err) {
if (err) {
- throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs
+ if (process.throwDeprecation)
+ throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs
+ else if (!process.noDeprecation) {
+ var msg = 'fs: missing callback ' + (err.stack || err.message);
+ if (process.traceDeprecation)
+ console.trace(msg);
+ else
+ console.error(msg);
+ }
}
- };
+ }
}
function maybeCallback(cb) {