Skip to content

Commit 9f76552

Browse files
committed
Add try-catch to handle potential upload errors in handleUploadFiles
1 parent 002acb5 commit 9f76552

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

web_src/js/features/comp/EditorUpload.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,13 @@ async function handleUploadFiles(editor, dropzoneEl, files, e) {
103103
// If not, the check upload process may fail
104104
const handleInsertPlaceholder = () => editor.insertPlaceholder(placeholder);
105105
dropzoneEl.dropzone.on('thumbnail', handleInsertPlaceholder);
106-
await uploadFile(dropzoneEl, file); // the "file" will get its "uuid" during the upload
107-
dropzoneEl.dropzone.off('thumbnail', handleInsertPlaceholder);
106+
try {
107+
await uploadFile(dropzoneEl, file); // the "file" will get its "uuid" during the upload
108+
} catch (err) {
109+
throw err;
110+
} finally {
111+
dropzoneEl.dropzone.off('thumbnail', handleInsertPlaceholder);
112+
}
108113
editor.replacePlaceholder(placeholder, generateMarkdownLinkForAttachment(file, {width, dppx}));
109114
}
110115
}

0 commit comments

Comments
 (0)