reformat fs errors, ensure syscall & path are included in message when present

This commit is contained in:
akhil 2014-06-03 11:46:19 -07:00
parent 83de95f5e3
commit 60793b1ccd
1 changed files with 17 additions and 6 deletions

View File

@ -605,12 +605,23 @@
}
var newError = function(exception) {
var error = new Error(exception.getErrnoMessage());
error.errno = exception.errno()
error.code = exception.errnoString();
error.message = exception.errnoString() + ', ' + exception.getErrnoMessage() + ' \'' + exception.path() +'\'';
error.path = exception.path();
process._errno = error.code;
var errno = exception.errno();
var errnoString = exception.errnoString();
var message = exception.getErrnoMessage();
var syscall = exception.syscall();
var path = exception.path();
var errorMessage =
errnoString + ', ' +
(syscall ? syscall : message) +
(path ? ' \'' + path +'\'' : '');
var error = new Error(errorMessage);
error.errno = errno;
error.code = errnoString;
if (path) error.path = path;
process._errno = errnoString;
return error;
}
});