| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7271cb0 commit 4a35ba4
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1219,7 +1219,9 @@ function FSWatcher() { | |||
| 1219 | 1219 | this._handle.onchange = function(status, event, filename) { | |
| 1220 | 1220 | if (status < 0) { | |
| 1221 | 1221 | self._handle.close(); | |
| 1222 | - self.emit('error', errnoException(status, 'watch')); | ||
| 1222 | + const error = errnoException(status, `watch ${filename}`); | ||
| 1223 | + error.filename = filename; | ||
| 1224 | + self.emit('error', error); | ||
| 1223 | 1225 | } else { | |
| 1224 | 1226 | self.emit('change', event, filename); | |
| 1225 | 1227 | } | |
@@ -1234,7 +1236,9 @@ FSWatcher.prototype.start = function(filename, persistent, recursive) { | |||
| 1234 | 1236 | recursive); | |
| 1235 | 1237 | if (err) { | |
| 1236 | 1238 | this._handle.close(); | |
| 1237 | - throw errnoException(err, 'watch'); | ||
| 1239 | + const error = errnoException(err, `watch ${filename}`); | ||
| 1240 | + error.filename = filename; | ||
| 1241 | + throw error; | ||
| 1238 | 1242 | } | |
| 1239 | 1243 | }; | |
| 1240 | 1244 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -126,3 +126,20 @@ assert.throws(function() { | |||
| 126 | 126 | w.stop(); | |
| 127 | 127 | }, TypeError); | |
| 128 | 128 | oldhandle.stop(); // clean up | |
| 129 | + | ||
| 130 | + assert.throws(function() { | ||
| 131 | + fs.watch('non-existent-file'); | ||
| 132 | + }, function(err) { | ||
| 133 | + assert(err); | ||
| 134 | + assert(/non-existent-file/.test(err)); | ||
| 135 | + assert.equal(err.filename, 'non-existent-file'); | ||
| 136 | + return true; | ||
| 137 | + }); | ||
| 138 | + | ||
| 139 | + var watcher = fs.watch(__filename); | ||
| 140 | + watcher.on('error', common.mustCall(function(err) { | ||
| 141 | + assert(err); | ||
| 142 | + assert(/non-existent-file/.test(err)); | ||
| 143 | + assert.equal(err.filename, 'non-existent-file'); | ||
| 144 | + })); | ||
| 145 | + watcher._handle.onchange(-1, 'ENOENT', 'non-existent-file'); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments