From adf8f3d1fee3850b2eaa227a74e45a6a27af61ac Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sun, 11 Oct 2020 13:12:50 -0400 Subject: [PATCH] fs: throw rm() validation errors This commit updates validateRmOptions() to throw on input validation failures. This is consistent with how Node handles validation in most places across the codebase. PR-URL: https://github.com/nodejs/node/pull/35602 Reviewed-By: Luigi Pinca Reviewed-By: Antoine du Hamel Reviewed-By: Joyee Cheung Reviewed-By: Rich Trott Reviewed-By: Richard Lau --- lib/internal/fs/utils.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/internal/fs/utils.js b/lib/internal/fs/utils.js index 183a0c0fee3ed4..b024ed034f8aea 100644 --- a/lib/internal/fs/utils.js +++ b/lib/internal/fs/utils.js @@ -673,12 +673,8 @@ const defaultRmdirOptions = { }; const validateRmOptions = hideStackFrames((path, options, callback) => { - try { - options = validateRmdirOptions(options, defaultRmOptions); - validateBoolean(options.force, 'options.force'); - } catch (err) { - return callback(err); - } + options = validateRmdirOptions(options, defaultRmOptions); + validateBoolean(options.force, 'options.force'); lazyLoadFs().stat(path, (err, stats) => { if (err) {