From be511ccdbdd204a796ac0631ee0a653ff54361ba Mon Sep 17 00:00:00 2001 From: franekmagiera Date: Sun, 11 Feb 2024 22:11:11 +0100 Subject: [PATCH] Add error logging --- app/src/get-youtube-video-summary.ts | 12 +++++++++++- run.ts | 8 +------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/src/get-youtube-video-summary.ts b/app/src/get-youtube-video-summary.ts index fcda79b..43cd06b 100644 --- a/app/src/get-youtube-video-summary.ts +++ b/app/src/get-youtube-video-summary.ts @@ -31,10 +31,20 @@ async function getYoutubeVideoSummary( ): Promise | InternalFailure> { const getYoutubeCaptionsResult = await getYoutubeCaptions(videoId); if (getYoutubeCaptionsResult.result === Result.Failure) { + console.error( + getYoutubeCaptionsResult.failure, + getYoutubeCaptionsResult.message || "", + ); // Couldn't get youtube captions, propagate the failure. return getYoutubeCaptionsResult; } const captions = getYoutubeCaptionsResult.data; - const summary = getCaptionsSummary(captions); + const summary = await getCaptionsSummary(captions); + if (summary.result === Result.Failure) { + console.error( + summary.failure, + summary.message || "", + ); + } return summary; } diff --git a/run.ts b/run.ts index 99c6dcc..8190596 100644 --- a/run.ts +++ b/run.ts @@ -22,13 +22,7 @@ async function run() { } else { const appConfig = appConfigResult.data; const summaryResult = await appConfig.getYoutubeVideoSummary(videoId); - if (summaryResult.result === Result.Failure) { - console.log( - summaryResult.failure, - "\n", - summaryResult.message, - ); - } else { + if (summaryResult.result === Result.Ok) { console.log(summaryResult.data); } }