Skip to content

Commit

Permalink
Add error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
franekmagiera committed Feb 11, 2024
1 parent ea595e1 commit be511cc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
12 changes: 11 additions & 1 deletion app/src/get-youtube-video-summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,20 @@ async function getYoutubeVideoSummary(
): Promise<Ok<string> | 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;
}
8 changes: 1 addition & 7 deletions run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit be511cc

Please sign in to comment.