|
|
@ -59,36 +59,22 @@ 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; |
|
|
|
callback = debugCallback; |
|
|
|
} else |
|
|
|
callback = missingCallback; |
|
|
|
|
|
|
|
return callback; |
|
|
|
|
|
|
|
function debugCallback(err) { |
|
|
|
if (err) { |
|
|
|
backtrace.message = err.message; |
|
|
|
err = backtrace; |
|
|
|
missingCallback(err); |
|
|
|
} |
|
|
|
return function(err) { |
|
|
|
if (err) { |
|
|
|
backtrace.message = err.message; |
|
|
|
err = backtrace; |
|
|
|
throw err; |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
function missingCallback(err) { |
|
|
|
return function(err) { |
|
|
|
if (err) { |
|
|
|
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); |
|
|
|
} |
|
|
|
throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs
|
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
function maybeCallback(cb) { |
|
|
|