From 714d3472d35e8b3450167af7193865c432dfab6e Mon Sep 17 00:00:00 2001 From: charlierudolph Date: Thu, 18 Jun 2015 11:12:30 -0700 Subject: [PATCH 1/3] fs.watch error message includes filename --- lib/fs.js | 4 ++-- test/simple/test-fs-watch-error.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 test/simple/test-fs-watch-error.js diff --git a/lib/fs.js b/lib/fs.js index daeb20e747ea..b69b0e45b521 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -1160,7 +1160,7 @@ function FSWatcher() { this._handle.onchange = function(status, event, filename) { if (status < 0) { self._handle.close(); - self.emit('error', errnoException(status, 'watch')); + self.emit('error', errnoException(status, 'watch ' + filename)); } else { self.emit('change', event, filename); } @@ -1175,7 +1175,7 @@ FSWatcher.prototype.start = function(filename, persistent, recursive) { recursive); if (err) { this._handle.close(); - throw errnoException(err, 'watch'); + throw errnoException(err, 'watch ' + filename); } }; diff --git a/test/simple/test-fs-watch-error.js b/test/simple/test-fs-watch-error.js new file mode 100644 index 000000000000..96747ee32769 --- /dev/null +++ b/test/simple/test-fs-watch-error.js @@ -0,0 +1,30 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var assert = require('assert'); +var fs = require('fs'); + +try { + fs.watch('non-existant-file') +} catch (error) { + assert(error); + assert(/non-existant-file/.test(error)); +} From 9e8464559487dae4c621e6d92c5200de075fb266 Mon Sep 17 00:00:00 2001 From: Charlie Rudolph Date: Thu, 2 Jul 2015 15:21:42 -0700 Subject: [PATCH 2/3] Update test-fs-watch-error.js --- test/simple/test-fs-watch-error.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/simple/test-fs-watch-error.js b/test/simple/test-fs-watch-error.js index 96747ee32769..21dbd357f6d9 100644 --- a/test/simple/test-fs-watch-error.js +++ b/test/simple/test-fs-watch-error.js @@ -23,7 +23,7 @@ var assert = require('assert'); var fs = require('fs'); try { - fs.watch('non-existant-file') + fs.watch('non-existent-file'); } catch (error) { assert(error); assert(/non-existant-file/.test(error)); From 68bfdee8e182685be78ae3343757e5a2db080e06 Mon Sep 17 00:00:00 2001 From: Charlie Rudolph Date: Thu, 2 Jul 2015 15:21:53 -0700 Subject: [PATCH 3/3] Update test-fs-watch-error.js --- test/simple/test-fs-watch-error.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/simple/test-fs-watch-error.js b/test/simple/test-fs-watch-error.js index 21dbd357f6d9..3603278959d8 100644 --- a/test/simple/test-fs-watch-error.js +++ b/test/simple/test-fs-watch-error.js @@ -26,5 +26,5 @@ try { fs.watch('non-existent-file'); } catch (error) { assert(error); - assert(/non-existant-file/.test(error)); + assert(/non-existent-file/.test(error)); }