From 219932a9f77f8a013d50067e931e6c877f9024d3 Mon Sep 17 00:00:00 2001 From: matzavinos Date: Sat, 26 Aug 2017 07:46:47 -0400 Subject: errors: convert 'fs' covert lib/fs.js over to using lib/internal/errors.js i have not addressed the cases that use errnoException(), for reasons described in GH-12926 - throw the ERR_INVALID_CALLBACK error when the the callback is invalid - replace the ['object', 'string'] with ['string', 'object'] in the error constructor call, to better match the previous err msg in the getOptions() function - add error ERR_VALUE_OUT_OF_RANGE in lib/internal/errors.js, this error is thrown when a numeric value is out of range - document the ERR_VALUE_OUT_OF_RANGE err in errors.md - correct the expected args, in the error thrown in the function fs._toUnixTimestamp() to ['Date', 'time in seconds'] (lib/fs.js) - update the listener error type in the fs.watchFile() function, from Error to TypeError (lib/fs.js) - update errors from ERR_INVALID_OPT_VALUE to ERR_INVALID_ARG_TYPE in the functions fs.ReadStream() and fs.WriteStream(), for the cases of range errors use the new error: ERR_VALUE_OUT_OF_RANGE (lib/fs.js) PR-URL: https://github.com/nodejs/node/pull/15043 Refs: https://github.com/nodejs/node/issues/11273 Reviewed-By: Refael Ackermann Reviewed-By: James M Snell Reviewed-By: Michael Dawson --- test/parallel/test-fs-watchfile.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'test/parallel/test-fs-watchfile.js') diff --git a/test/parallel/test-fs-watchfile.js b/test/parallel/test-fs-watchfile.js index 43e2594463..f980d8f3fc 100644 --- a/test/parallel/test-fs-watchfile.js +++ b/test/parallel/test-fs-watchfile.js @@ -6,13 +6,23 @@ const fs = require('fs'); const path = require('path'); // Basic usage tests. -assert.throws(function() { - fs.watchFile('./some-file'); -}, /^Error: "watchFile\(\)" requires a listener function$/); +common.expectsError( + () => { + fs.watchFile('./some-file'); + }, + { + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError + }); -assert.throws(function() { - fs.watchFile('./another-file', {}, 'bad listener'); -}, /^Error: "watchFile\(\)" requires a listener function$/); +common.expectsError( + () => { + fs.watchFile('./another-file', {}, 'bad listener'); + }, + { + code: 'ERR_INVALID_ARG_TYPE', + type: TypeError + }); assert.throws(function() { fs.watchFile(new Object(), common.mustNotCall()); -- cgit v1.2.3