Skip to content

Commit

Permalink
replaced throw with promise.reject
Browse files Browse the repository at this point in the history
  • Loading branch information
vishvamsinh28 committed Oct 17, 2024
1 parent a5c083b commit 49f308a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/build-rss.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module.exports = async function rssFeed(type, title, desc, outputPath) {

for (let post of posts) {
if (!post.title || !post.slug || !post.excerpt || !post.date) {
throw new Error('Missing required fields in post data');
return Promise.reject(new Error('Missing required fields in post data'));
}
const link = `${base}${post.slug}${tracking}`;
const { title, excerpt, date } = post;
Expand Down Expand Up @@ -94,6 +94,6 @@ module.exports = async function rssFeed(type, title, desc, outputPath) {
await fs.writeFile(`./public/${outputPath}`, xml, 'utf8');
return `RSS feed generated successfully at ${outputPath}`;
} catch (err) {
throw new Error(`Failed to generate RSS feed: ${err.message}`);
return Promise.reject(new Error(`Failed to generate RSS feed: ${err.message}`));
}
};

0 comments on commit 49f308a

Please sign in to comment.