From c6b6c92185316e13738e6fa931fdd5303e381e46 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Mon, 19 Mar 2018 13:33:46 +0100 Subject: lib: always show ERR_INVALID_ARG_TYPE received part This makes a effort to make sure all of these errors will actually also show the received input. On top of that it refactors a few tests for better maintainability. It will also change the returned type to always be a simple typeof instead of special handling null. PR-URL: https://github.com/nodejs/node/pull/19445 Reviewed-By: James M Snell Reviewed-By: Matteo Collina Reviewed-By: Joyee Cheung Reviewed-By: Anna Henningsen --- lib/path.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/path.js') diff --git a/lib/path.js b/lib/path.js index 427d158e7a7..90129f1f529 100644 --- a/lib/path.js +++ b/lib/path.js @@ -36,7 +36,7 @@ const { function assertPath(path) { if (typeof path !== 'string') { - throw new ERR_INVALID_ARG_TYPE('path', 'string'); + throw new ERR_INVALID_ARG_TYPE('path', 'string', path); } } @@ -747,7 +747,7 @@ const win32 = { basename: function basename(path, ext) { if (ext !== undefined && typeof ext !== 'string') - throw new ERR_INVALID_ARG_TYPE('ext', 'string'); + throw new ERR_INVALID_ARG_TYPE('ext', 'string', ext); assertPath(path); var start = 0; var end = -1; @@ -1295,7 +1295,7 @@ const posix = { basename: function basename(path, ext) { if (ext !== undefined && typeof ext !== 'string') - throw new ERR_INVALID_ARG_TYPE('ext', 'string'); + throw new ERR_INVALID_ARG_TYPE('ext', 'string', ext); assertPath(path); var start = 0; -- cgit v1.2.3