From 8bb60e3c8dde6f0c0295309291b4022937072c04 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Mon, 7 Mar 2016 12:19:48 -0800 Subject: [PATCH] fs: improve error message for invalid flag Flags on fs.open and others can be passed as strings or int. Previously, if passing anything other than string or int, the error message would only say that flags must be an int. PR-URL: https://github.com/nodejs/node/pull/5590 Reviewed-By: Colin Ihrig Reviewed-By: Myles Borins Reviewed-By: Ben Noordhuis --- lib/fs.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fs.js b/lib/fs.js index 1fd40b9f4f..9aa4eaa6a5 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -536,8 +536,8 @@ fs.readFileSync = function(path, options) { // Used by binding.open and friends function stringToFlags(flag) { - // Only mess with strings - if (typeof flag !== 'string') { + // Return early if it's a number + if (typeof flag === 'number') { return flag; }