Skip to content

Commit 2b31f66

Browse files
committed
fix: file upload error
1 parent e7ba448 commit 2b31f66

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/features/editor/FullscreenDropzone.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,15 @@ export const FullscreenDropzone = () => {
2121
]}
2222
onReject={files => toast.error(`Unable to load file ${files[0].file.name}`)}
2323
onDrop={async e => {
24-
const fileContent = await e[0].text();
25-
let fileExtension = e[0].name.split(".").pop() as FileFormat | undefined;
26-
if (!fileExtension) fileExtension = FileFormat.JSON;
27-
setContents({ contents: fileContent, format: fileExtension, hasChanges: false });
24+
try {
25+
const fileContent = await e[0].text();
26+
let fileExtension = e[0].name.split(".").pop() as FileFormat | undefined;
27+
if (!fileExtension) fileExtension = FileFormat.JSON;
28+
setContents({ contents: fileContent, format: fileExtension, hasChanges: false });
29+
} catch (err) {
30+
toast.error("An error occurred while reading the file.");
31+
console.error(err);
32+
}
2833
}}
2934
>
3035
<Group

0 commit comments

Comments
 (0)