From 3a378515ef515ac2f9e2ecc824f47ad96685650e Mon Sep 17 00:00:00 2001 From: Bruno Jouhier Date: Sat, 14 Feb 2015 17:50:08 +0100 Subject: [PATCH] improved makeCallback arg checking --- lib/fs.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/fs.js b/lib/fs.js index f582545d0fb2..f89b597224e8 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -91,9 +91,12 @@ function maybeCallback(cb) { // for callbacks that are passed to the binding layer, callbacks that are // invoked from JS already run in the proper scope. function makeCallback(cb) { - if (!util.isFunction(cb)) { + if (util.ifNullOrUndefined(cb)) { return rethrow(); } + if (!util.isFunction(cb)) { + throw new Error('callback must be a function'); + } return function() { return cb.apply(null, arguments);