From 2312a5730c407edf6377a073c021fea91b814abf Mon Sep 17 00:00:00 2001 From: Vishvamsinh Vaghela Date: Fri, 1 Nov 2024 15:39:33 +0530 Subject: [PATCH] replaced promise.reject with throw --- scripts/build-rss.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/build-rss.js b/scripts/build-rss.js index c05d14a71a9..444580c344a 100644 --- a/scripts/build-rss.js +++ b/scripts/build-rss.js @@ -30,7 +30,7 @@ module.exports = async function rssFeed(type, title, desc, outputPath) { }); if (missingDatePosts.length > 0) { - return Promise.reject(new Error('Missing date in post data')); + throw new Error('Missing date in post data'); } const base = 'https://www.asyncapi.com' @@ -60,7 +60,7 @@ module.exports = async function rssFeed(type, title, desc, outputPath) { !post.title || !post.slug || !post.excerpt || !post.date ); if (invalidPosts.length > 0) { - return Promise.reject(new Error('Missing required fields in post data')); + throw new Error('Missing required fields in post data'); } const link = `${base}${post.slug}${tracking}`; const { title, excerpt, date } = post; @@ -96,6 +96,6 @@ module.exports = async function rssFeed(type, title, desc, outputPath) { const xml = json2xml.getXml(feed, '@', '', 2); await fs.writeFile(`./public/${outputPath}`, xml, 'utf8'); } catch (err) { - return Promise.reject(new Error(`Failed to generate RSS feed: ${err.message}`)); + throw new Error(`Failed to generate RSS feed: ${err.message}`); } };