Skip to content

✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.

fix: file upload error

AykutSarac2b31f6648abd
diff --git a/src/features/editor/FullscreenDropzone.tsx b/src/features/editor/FullscreenDropzone.tsx
index 224e073f..eaab7f94 100644
--- a/src/features/editor/FullscreenDropzone.tsx
+++ b/src/features/editor/FullscreenDropzone.tsx
@@ -21,10 +21,15 @@ export const FullscreenDropzone = () => {
]}
onReject={files => toast.error(`Unable to load file ${files[0].file.name}`)}
onDrop={async e => {
- const fileContent = await e[0].text();
- let fileExtension = e[0].name.split(".").pop() as FileFormat | undefined;
- if (!fileExtension) fileExtension = FileFormat.JSON;
- setContents({ contents: fileContent, format: fileExtension, hasChanges: false });
+ try {
+ const fileContent = await e[0].text();
+ let fileExtension = e[0].name.split(".").pop() as FileFormat | undefined;
+ if (!fileExtension) fileExtension = FileFormat.JSON;
+ setContents({ contents: fileContent, format: fileExtension, hasChanges: false });
+ } catch (err) {
+ toast.error("An error occurred while reading the file.");
+ console.error(err);
+ }
}}
>
<Group