fs: add error code on null byte paths
This commit adds a code field to the error returned by nullCheck(). Fixes: https://github.com/iojs/io.js/issues/517 PR-URL: https://github.com/iojs/io.js/pull/519 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
parent
e2558f02df
commit
03ee4d8547
@ -86,6 +86,7 @@ function assertEncoding(encoding) {
|
|||||||
function nullCheck(path, callback) {
|
function nullCheck(path, callback) {
|
||||||
if (('' + path).indexOf('\u0000') !== -1) {
|
if (('' + path).indexOf('\u0000') !== -1) {
|
||||||
var er = new Error('Path must be a string without null bytes.');
|
var er = new Error('Path must be a string without null bytes.');
|
||||||
|
er.code = 'ENOENT';
|
||||||
if (!callback)
|
if (!callback)
|
||||||
throw er;
|
throw er;
|
||||||
process.nextTick(function() {
|
process.nextTick(function() {
|
||||||
|
@ -7,6 +7,7 @@ function check(async, sync) {
|
|||||||
var argsSync = Array.prototype.slice.call(arguments, 2);
|
var argsSync = Array.prototype.slice.call(arguments, 2);
|
||||||
var argsAsync = argsSync.concat(function(er) {
|
var argsAsync = argsSync.concat(function(er) {
|
||||||
assert(er && er.message.match(expected));
|
assert(er && er.message.match(expected));
|
||||||
|
assert.equal(er.code, 'ENOENT');
|
||||||
});
|
});
|
||||||
|
|
||||||
if (sync)
|
if (sync)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user