fs: make fs.watch error message more useful

PR-URL: https://github.com/nodejs/node/pull/5616
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
This commit is contained in:
James M Snell 2016-03-17 18:14:37 -07:00
parent 060e5f0c00
commit 53a95a5b12

View File

@ -1382,7 +1382,10 @@ function FSWatcher() {
this._handle.onchange = function(status, event, filename) {
if (status < 0) {
self._handle.close();
const error = errnoException(status, `watch ${filename}`);
const error = !filename ?
errnoException(status, 'Error watching file for changes:') :
errnoException(status,
`Error watching file ${filename} for changes:`);
error.filename = filename;
self.emit('error', error);
} else {