From 53a95a5b12fbbfc8d465689e43aa77da32e5d0f3 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Thu, 17 Mar 2016 18:14:37 -0700 Subject: [PATCH] fs: make fs.watch error message more useful PR-URL: https://github.com/nodejs/node/pull/5616 Reviewed-By: Ben Noordhuis Reviewed-By: Trevor Norris --- lib/fs.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/fs.js b/lib/fs.js index f4a31a6f4d44c2..bfb7d874f7d71f 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -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 {