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 <cjihrig@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
James M Snell 2016-03-07 12:19:48 -08:00
parent 3c8475241d
commit 8bb60e3c8d

View File

@ -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;
}