From 3b45c05a23d40a203416548492845b3d82efb318 Mon Sep 17 00:00:00 2001 From: Mohammed Keyvanzadeh Date: Sat, 22 Jan 2022 03:16:16 +0330 Subject: [PATCH] process: use validateString validator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the `validateString()` validator where applicable. PR-URL: https://github.com/nodejs/node/pull/41595 Reviewed-By: Colin Ihrig Reviewed-By: Michaƫl Zasso Reviewed-By: Benjamin Gruenbaum Reviewed-By: Antoine du Hamel Reviewed-By: Mestery Reviewed-By: Luigi Pinca --- lib/internal/process/report.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/internal/process/report.js b/lib/internal/process/report.js index f34b71abe57d46..b07fd0c1ff6eb7 100644 --- a/lib/internal/process/report.js +++ b/lib/internal/process/report.js @@ -1,6 +1,5 @@ 'use strict'; const { - ERR_INVALID_ARG_TYPE, ERR_SYNTHETIC } = require('internal/errors').codes; const { @@ -18,9 +17,11 @@ const report = { if (typeof file === 'object' && file !== null) { err = file; file = undefined; - } else if (file !== undefined && typeof file !== 'string') { - throw new ERR_INVALID_ARG_TYPE('file', 'String', file); - } else if (err === undefined) { + } else if (file !== undefined) { + validateString(file, 'file'); + } + + if (err === undefined) { err = new ERR_SYNTHETIC(); } else { validateObject(err, 'err');