From bee9831f406bbf1eef00fafae72342a5dbe3e3fe Mon Sep 17 00:00:00 2001 From: Kazuki Yamada Date: Sat, 24 Aug 2024 22:44:58 +0900 Subject: [PATCH] =?UTF-8?q?feat(feed):=20=E3=83=95=E3=82=A3=E3=83=BC?= =?UTF-8?q?=E3=83=89=E7=94=9F=E6=88=90=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89?= =?UTF-8?q?=E3=81=AE=E3=82=A8=E3=83=A9=E3=83=BC=E3=83=8F=E3=83=B3=E3=83=89?= =?UTF-8?q?=E3=83=AA=E3=83=B3=E3=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/feed/generate-feed-command.ts | 58 ++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/src/feed/generate-feed-command.ts b/src/feed/generate-feed-command.ts index bfc48d08d8c8..ae49bbc15c6d 100644 --- a/src/feed/generate-feed-command.ts +++ b/src/feed/generate-feed-command.ts @@ -41,25 +41,49 @@ const feedImagePrecacher = new FeedImagePrecacher(); ); // まとめフィードのバリデーション。エラーならすぐに終了する - await feedValidator.assertFeed(generateFeedsResult.aggregatedFeed); - await feedValidator.assertXmlFeed('atom', generateFeedsResult.feedDistributionSet.atom); - await feedValidator.assertXmlFeed('rss', generateFeedsResult.feedDistributionSet.rss); + try { + await feedValidator.assertFeed(generateFeedsResult.aggregatedFeed); + await feedValidator.assertXmlFeed('atom', generateFeedsResult.feedDistributionSet.atom); + await feedValidator.assertXmlFeed('rss', generateFeedsResult.feedDistributionSet.rss); + } catch (e) { + const error = new Error('Failed to validate feed', { + cause: e, + }); + console.error(error); + throw error; + } // ファイル出力 - await feedStorer.storeFeeds( - generateFeedsResult.feedDistributionSet, - STORE_FEEDS_DIR_PATH, - crawlFeedsResult.feeds, - ogObjectMap, - crawlFeedsResult.feedItemHatenaCountMap, - STORE_BLOG_FEEDS_DIR_PATH, - ); + try { + await feedStorer.storeFeeds( + generateFeedsResult.feedDistributionSet, + STORE_FEEDS_DIR_PATH, + crawlFeedsResult.feeds, + ogObjectMap, + crawlFeedsResult.feedItemHatenaCountMap, + STORE_BLOG_FEEDS_DIR_PATH, + ); + } catch (e) { + const error = new Error('Failed to store feeds', { + cause: e, + }); + console.error(error); + throw error; + } // 画像の事前キャッシュ - await feedImagePrecacher.fetchAndCacheFeedImages( - crawlFeedsResult.feeds, - crawlFeedsResult.feedItems, - ogObjectMap, - FETCH_IMAGE_CONCURRENCY, - ); + try { + await feedImagePrecacher.fetchAndCacheFeedImages( + crawlFeedsResult.feeds, + crawlFeedsResult.feedItems, + ogObjectMap, + FETCH_IMAGE_CONCURRENCY, + ); + } catch (e) { + const error = new Error('Failed to cache feed images', { + cause: e, + }); + console.error(error); + throw error; + } })();