refactor: implement error handling for video download and PPTX export in video presentation component

This commit is contained in:
Anish Sarkar 2026-03-24 23:57:32 +05:30
parent fde8faec7e
commit c894185102
2 changed files with 44 additions and 6 deletions

View file

@ -18,6 +18,7 @@ import {
buildSlideWithWatermark,
type CompiledSlide,
} from "./combined-player";
import { getVideoDownloadErrorToast, getPptxExportErrorToast } from "./errors";
const GenerateVideoPresentationArgsSchema = z.object({
source_content: z.string(),
@ -68,6 +69,7 @@ type GenerateVideoPresentationArgs = z.infer<typeof GenerateVideoPresentationArg
type GenerateVideoPresentationResult = z.infer<typeof GenerateVideoPresentationResultSchema>;
type VideoPresentationStatusResponse = z.infer<typeof VideoPresentationStatusResponseSchema>;
function parseStatusResponse(data: unknown): VideoPresentationStatusResponse | null {
const result = VideoPresentationStatusResponseSchema.safeParse(data);
if (!result.success) {
@ -321,9 +323,8 @@ function VideoPresentationPlayer({
URL.revokeObjectURL(url);
} catch (err) {
if ((err as Error).name !== "AbortError") {
toast.error("Download Failed", {
description: err instanceof Error ? err.message : "Failed to render video",
});
const { title, description } = getVideoDownloadErrorToast(err);
toast.error(title, { description });
}
} finally {
setIsRendering(false);
@ -396,9 +397,8 @@ function VideoPresentationPlayer({
for (const r of roots) r.unmount();
document.body.removeChild(offscreen);
} catch (err) {
toast.error("PPTX Export Failed", {
description: err instanceof Error ? err.message : "Failed to export PPTX",
});
const { title, description } = getPptxExportErrorToast(err);
toast.error(title, { description });
} finally {
setIsPptxExporting(false);
setPptxProgress(null);