Skip to content

Commit

Permalink
replaced promise.reject with throw
Browse files Browse the repository at this point in the history
  • Loading branch information
vishvamsinh28 committed Nov 1, 2024
1 parent 87eb06b commit 2312a57
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions scripts/build-rss.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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}`);
}
};

0 comments on commit 2312a57

Please sign in to comment.