Skip to content

Commit 13dbe01

Browse files
authored
Merge pull request #91 from devniel/main
refactor: add try/catch to saveVideoFile
2 parents 666c3ce + 8850793 commit 13dbe01

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

packages/app/src/services/io/useIO.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,15 @@ export const useIO = create<IOStore>((set, get) => ({
525525
const { saveAnyFile } = get()
526526
console.log(`rendering project using the embedded FFmpeg..`)
527527

528+
const task = useTasks.getState().add({
529+
category: TaskCategory.EXPORT,
530+
visibility: TaskVisibility.BLOCKER,
531+
initialMessage: `Rendering the project to MP4..`,
532+
successMessage: `Successfully exported the MP4 video!`,
533+
value: 0,
534+
})
535+
536+
try {
528537
const timeline: TimelineStore = useTimeline.getState()
529538

530539
const {
@@ -540,14 +549,6 @@ export const useIO = create<IOStore>((set, get) => ({
540549
throw new Error(`cannot save a clap.. if there is no clap`)
541550
}
542551

543-
const task = useTasks.getState().add({
544-
category: TaskCategory.EXPORT,
545-
visibility: TaskVisibility.BLOCKER,
546-
initialMessage: `Rendering the project to MP4..`,
547-
successMessage: `Successfully exported the MP4 video!`,
548-
value: 0,
549-
})
550-
551552
const ignoreThisVideoSegmentId = (await getFinalVideo(clap))?.id || ''
552553

553554
const segments: ExportableSegment[] = timelineSegments
@@ -633,6 +634,10 @@ export const useIO = create<IOStore>((set, get) => ({
633634
const videoBlob = new Blob([fullVideo], { type: 'video/mp4' })
634635
saveAnyFile(videoBlob, 'my_project.mp4')
635636
task.success()
637+
} catch (err) {
638+
console.error(err)
639+
task.fail(`${err || 'unknown error'}`)
640+
}
636641
},
637642

638643
saveZipFile: async () => {

0 commit comments

Comments
 (0)